Forum Discussion

philosophie_e's avatar
4 years ago
Solved

MAX with condition

Hello, I need some support in establishing status for countries using MAX function (or potentially any other). I have three tables: Table 1 with name of countries where I want to have the final ...
  • smpa01's avatar
    smpa01
    4 years ago

    philosophie_e 

    Column = 
    VAR _status =
        CALCULATE(COUNT ( Table2[Status] ),ALLEXCEPT(Table1,Table1[Country]))
    VAR _live =
        CALCULATE ( COUNT ( Table2[Status] ), Table2[Status] = "Live" )
    VAR _ongoing =
        CALCULATE ( COUNT ( Table2[Status] ), Table2[Status] = "Ongoing" )
    VAR _scheduled =
        CALCULATE ( COUNT ( Table2[Status] ), Table2[Status] = "Scheduled" )
    RETURN
        SWITCH (
            TRUE (),
            _live <> BLANK ()
                && _live = _status, "Fully Live",
            _live <> BLANK ()
                && _live <> _status, "Partially Live",
            _ongoing <> BLANK ()
                && _ongoing = _status, "Ongoing",
            _scheduled <> BLANK ()
                && _scheduled = _status, "Scheduled","Not Live"
        )