Forum Discussion

Smartnag's avatar
Smartnag
Frequent Visitor
4 years ago
Solved

In Statement in sql, same in power bi

Hi All,   Need help on below.   =Max([CD] In ([Bookinghour]) )  is in SQL.   Both CD and Bookinghour  are the columns.   Same how to achieve in Dax.   Thanks, Nag    
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Smartnag,

    Did you mean to get the 'CD' value based on the max 'bookinghours', right?
    If that is the case, you can get the max 'bookinghours' first, then you can use this as a condition to find out the CD value.

    formula =
    VAR maxHour =
        CALCULATE ( MAX ( Table[Bookinghour] ), ALLSELECTED ( Table ) )
    RETURN
        CALCULATE (
            MAX ( Table[CD] ),
            FILTER ( ALLSELECTED ( Table ), [Bookinghour] = maxHour )
        )

    Regards,

    Xiaoxin Sheng