Forum Discussion

angelikakolacz's avatar
3 years ago
Solved

Compound DAX formula. FILTER, MAX and IF

Hello,   I need help. I'm looking for a DAX formula that gives me the next output:    Account number Invoice number Category Output 100465-8-2020 810000004022584 1 0 100465-8-2020 ...
  • v-yinliw-msft's avatar
    v-yinliw-msft
    3 years ago

    Hi angelikakolacz ,

     

    You can try this method:

     

    Add a index column first.

     

    New measure:

    Count =
    CALCULATE (
        COUNTROWS ( InvoiceTable ),
        FILTER (
            ALL ( InvoiceTable ),
            [Account Number] = MAX ( 'InvoiceTable'[Account Number] )
                && [Type] = MAX ( 'InvoiceTable'[Type] )
        )
    )
    
    Output =
    VAR _a =
        CALCULATE (
            MAX ( InvoiceTable[Invoice number] ),
            FILTER (
                ALL ( 'InvoiceTable' ),
                [Account Number] = MAX ( 'InvoiceTable'[Account Number] )
                    && [Categoru] = 1
            )
        )
    RETURN
        IF ( MAX ( 'InvoiceTable'[Invoice number] ) = _a, _a, 0 )
    

     

    The table looks like:

     

    Is this what you expect?

    Hope this helps you.

    Here is the PBIX file.

     

    Best Regards,

    Community Support Team _Yinliw

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.