Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Why this measuare is very very slow?
Mesuare =
VAR sum1 = [mesuare1] - [measure2]
VAR sum2 = [mesuare3] - [measure4]
VAR discount =
SWITCH (
TRUE (),
"disc1" IN DISTINCT ( Table2[name1] ), sum1, //Here i need toggle sum1 form negative to positive only for "disc1" values
"disc2" IN DISTINCT ( Table2[name1] ), sum1, //Here i need toggle sum1 form negative to positive only for "disc2" values
-sum1 //Here i need toggle sum1 form negative to positive for other
)
RETURN
SWITCH (
TRUE (),
"Name1" IN DISTINCT ( Table1[name] ), discount, // Show this sum in Name1 having values
"Name2" IN DISTINCT ( Table1[name] ), sum2 // Show this sum in Name2 having values
)
How to speedup it?
Solved! Go to Solution.
Hi @Analitika ,
There are 2 "switch" funtion in the sam measure that may take much CPU in calculation,pls try to replace the first switch funtion with "if",you may try to modify as below:
VAR discount =
IF (
"disc1" IN DISTINCT ( Table2[name1] )|| "disc2" IN DISTINCT ( Table2[name1] ), sum1, -sum1
)
Hi @Analitika ,
There are 2 "switch" funtion in the sam measure that may take much CPU in calculation,pls try to replace the first switch funtion with "if",you may try to modify as below:
VAR discount =
IF (
"disc1" IN DISTINCT ( Table2[name1] )|| "disc2" IN DISTINCT ( Table2[name1] ), sum1, -sum1
)
@Analitika , please let us know what are trying to achieve here
I need toggle wrong negatives sum if this is discounts
Hi @Analitika ,
First thing SWITCH function returns a scalar value, but in your DAX you are trying to return a table against "VAR discount".
What you can do is convert this "VAR discount" variable to a measure, then use it in your SWITCH statement which is in RETURN part of your dax expression.
Thanks,
Pragati
User | Count |
---|---|
78 | |
74 | |
62 | |
61 | |
45 |
User | Count |
---|---|
108 | |
100 | |
91 | |
83 | |
61 |