Forum Discussion

TrongPhuoc's avatar
TrongPhuoc
Frequent Visitor
2 years ago
Solved

Problem with IF DAX Funtion!

Hi everyone, I just give a try with a lated version of PowerBI Deskop   I met a weird situation, can anyone explain it to me? I have a max value =0.0541, and I just want to create a color code...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi TrongPhuoc ,

    Please try below steps:

    1. create measure with below dax formula

    Measure =
    VAR max_date =
        MAXX ( ALL ( 'Table' ), 'Table'[Date] )
    VAR tmp =
        FILTER ( ALL ( 'Table' ), 'Table'[Date] = max_date )
    VAR max_val =
        MAXX ( tmp, [CriticalVal] )
    VAR _a =
        CALCULATETABLE (
            VALUES ( 'Table'[order1] ),
            FILTER ( tmp, [CriticalVal] = max_val )
        )
    VAR cur_date =
        SELECTEDVALUE ( 'Table'[Date] )
    VAR cur_order =
        SELECTEDVALUE ( 'Table'[order1] )
    RETURN
        IF ( AND ( cur_date = max_date, cur_order IN _a ), 1 )
    
    Measure 2 =
    VAR max_date =
        MAXX ( ALL ( 'Table' ), 'Table'[Date] )
    VAR tmp =
        FILTER ( ALL ( 'Table' ), 'Table'[Date] = max_date )
    VAR max_val =
        MAXX ( tmp, [CriticalVal] )
    RETURN
        IF ( MAX ( 'Table'[CriticalVal] ) = max_val, "red" )
    

    2. add table visual with fields

     

    3. set visual level filter and conditional format for font color

     

    Please refer the attached .pbix file.

     

    Best regards,
    Community Support Team_Binbin Yu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • TrongPhuoc's avatar
    1 year ago

    Thank you very much!