Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello When i combine Variables with Switch statement it doesn’t work. But instead of variables I write entire calculation it work perfectly.
Below are 2 scenario of my measure, The first scenario doesn’t work if i use variable, but second work perfectly if i don't use variables. (The Dark Grey Bar's are the one causing issue)
Can anyone please help what i am doing wrong in first scenario.
merry christmas
scenario 1 (Incorrect) :-
Solved! Go to Solution.
Hi @Anonymous ,
check this out.
Test Measure2 =
CALCULATE (
CALCULATE (
SUM ( MOR_Data[Current month Fully Loaded Costs Euro] ),
SAMEPERIODLASTYEAR ( 'Calendar'[Date] )
),
FILTER (
'Calendar',
CONTAINS (
VALUES ( Axis_Table[Values] ),
Axis_Table[Values], SWITCH (
SELECTEDVALUE ( Axis_Table[Type]),
"Year", 'Calendar'[Year_Cal],
"Quarter", 'Calendar'[Quater-Year],
"Month", 'Calendar'[MonthYear_Cal]
)
)
)
)
Regards,
Marcus
Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.
Hi @Anonymous ,
I'd like to suggest you use in operator to replace TREATAS function, it also works to compare unrelated fields and list of values:
Total_workforce_FLC EURO(M/Y-1)2 =
IF (
HASONEVALUE ( 'Axis_Table'[Type] ),
CALCULATE (
CALCULATE (
SUM ( MOR_Data[Current month Fully Loaded Costs Euro] ),
SAMEPERIODLASTYEAR ( 'Calendar'[Date] )
),
FILTER (
'Calendar',
SWITCH (
SELECTEDVALUE ( Axis_Table[Type] ),
"Year", 'Calendar'[Year_Cal] IN VALUES ( 'Axis_Table'[Values] ),
"Month", 'Calendar'[MonthYear_Cal] IN VALUES ( 'Axis_Table'[Values] ),
"Quarter", 'Calendar'[Quater-Year] IN VALUES ( 'Axis_Table'[Values] )
)
)
)
)
Regards,
Xiaoxin Sheng
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
99 | |
83 | |
70 | |
60 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |