Nested Iteration in DAX

@Sairam If you are looking to break the code to easily understand it, then you can use variables, I solved a similar question a couple of days ago so here is the commented code.

Test =
CALCULATE (
    [Total Sales],
    FILTER (
        VALUES ( Customers[Customer Name] ),
        VAR TotalTransactions = [Total Transactions] 
        -- ^ Store the measure in a variable
        VAR CustomerSegmentation =
            FILTER (
                'Purchase Frequency',
                TotalTransactions > 'Purchase Frequency'[Min]
                    && TotalTransactions < 'Purchase Frequency'[Max]
            ) 
        -- ^ Get all the customers that fall between the current boundaries
        VAR TotalCount =
            COUNTROWS ( CustomerSegmentation ) -- Count if anything is returned
        RETURN
            TotalCount 
            -- If COUNTROWS = 0 then FILTER won't return anything as 0 = FALSE
            -- If COUNTROWS returns > 0 then return the customer names that 
            -- have Total Transactions within the boundaries of 'Purchase Frequency' 
            -- as non zero numbers = TRUE
    )
)

From the below images you can see that 0 is FALSE and non zero number is TRUE

1 Like