Forum Discussion

klehar's avatar
klehar
Helper V
4 years ago

Combining measures into a switch statement

Hi,

 

I'm trying to combine some measures using a switch statement in a calculated column but I get this error

 

Here is my dax

 

 

Forecast Actual = 

VAR Total_Upside =
    CALCULATE (
        [Total Value],
        'Table1'[Forecast Category] IN { "Upside" }
    )
VAR Total_Won =
    CALCULATE (
        [Total Value],
        'Table1'[Forecast Category] IN { "Won" }
    )
VAR Total_Commit =
    CALCULATE (
        [Total Value],
        'Table1'[Forecast Category] IN { "Commit" }
    )
RETURN
    SWITCH (
        TRUE (),
        "Commit", Total_Commit,
        "Won", Total_Won,
        "Upside", Total_Upside,
        "Unforecasted"
    )

 

 

How can i resolve this?

I want to use the above created calculated column on my legend shelf of bar chart

7 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    klehar You should replace in SWITCH function texts ("commit", "won" etc.) with conditions (equal, greater than etc.), that is SWITCH(TRUE(), 'something'="Commit", Total_Comit, 'something_else'="Won", Total_Won, ....)

    • klehar's avatar
      klehar
      Helper V

      Im already handling boolean logic in variables. hence i thought this would work

      • Anonymous's avatar
        Anonymous
        Not applicable

        If you check in SWITCH function whether value is equal to TRUE() (expression as the first parameter) then that value have to be boolean.