Forum Discussion

Saxon10's avatar
Saxon10
Icon for Post Prodigy rankPost Prodigy
4 years ago
Solved

Calculate Min/max column (Dax)

Hi,   I have table and the table contains the following columns are item and country code.   Query1   The same item has two different country code are ADMK and DMK. If same item has two differe...
  • CNENFRNL's avatar
    CNENFRNL
    4 years ago

    You can easily replicate the logic of Excel formula in calcualted column,

  • v-kkf-msft's avatar
    v-kkf-msft
    4 years ago

    Hi Saxon10 ,

     

    Please try the following calculated columns:

     

    Column = 
    VAR DMK =
        CALCULATE (
            COUNTROWS ( DATA ),
            FILTER (
                DATA,
                DATA[item] = EARLIER ( DATA[item] )
                    && DATA[country code] = "DMK"
            )
        )
    RETURN
        IF ( DMK > 0, "DMK", [country code] )

    Result = 
    VAR code =
        CALCULATE (
            MAX ( DATA[Column] ),
            KEEPFILTERS ( DATA[item] = EARLIER ( REPORT[Item] ) )
        )
    RETURN
        COALESCE ( code, "NA" )

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.