Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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
@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, ....)
Im already handling boolean logic in variables. hence i thought this would work
If you check in SWITCH function whether value is equal to TRUE() (expression as the first parameter) then that value have to be boolean.
So what can i do to make this into an expression or combine the above measures into a switch statement
Try this:
Forecast Actual=
SWITCH(TRUE(),
'Table1'[Forecast Category] IN {"Upside"},
CALCULATE(
[Total Value],
'Table1'[Forecast Category] IN {"Upside"}
),
'Table1'[Forecast Category] IN {"Won"},
CALCULATE(
[Total Value],
'Table1'[Forecast Category] IN {"Won"}
),
'Table1'[Forecast Category] IN {"Comit"},
CALCULATE(
[Total Value],
'Table1'[Forecast Category] IN {"Comit"}
),
"Unforcasted"
)
It gives me the following error
Forecast Actual=
IF(HASONEVALUE('Table1'[Forecast Category]),
SWITCH(TRUE(),
VALUES('Table1'[Forecast Category]) IN {"Upside"},
CALCULATE(
[Total Value],
'Table1'[Forecast Category] IN {"Upside"}
),
VALUES('Table1'[Forecast Category]) IN {"Won"},
CALCULATE(
[Total Value],
'Table1'[Forecast Category] IN {"Won"}
),
VALUES('Table1'[Forecast Category]) IN {"Commit"},
CALCULATE(
[Total Value],
'Table1'[Forecast Category] IN {"Commit"}
),
"Unforcasted"
))
User | Count |
---|---|
94 | |
77 | |
71 | |
62 | |
58 |
User | Count |
---|---|
110 | |
103 | |
84 | |
65 | |
62 |