Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I have a measure calculating for 4 different categories look like the below:
var _a = CALCULATE(....)
var _b = CALCULATE(...)
var sum_a = CALCULATE(...)
var sum_b = CALCULATE(...)
What I want to get is that when the category is a show calculation of a, b c, and d.
category | calculation |
a | a/sum of a |
b | b / sum of b |
...
But I cannot write the part after the return function.
Should like like this i believe:
return
if category is a:
then DIVIDE(_a, sum_a),
if category is b:
then divide (_b, sum_b)
I used ISFILTERED(Category) it works, but when I want to filter it with a date using a slicer, the filter is not applying.
I cant add the date filter after the return function because dates are not certain and I want to leave it to the user to choose it with a slicer.
How can I get the multiple outputs without using the ISFILTERED function because it disables the date slicer?
Solved! Go to Solution.
Hi @frknklcsln ,
Please have a try.
performance measure=
var _a = calculate(...)
var _b = calculate(...)
var _c = calculate(...)
var _d= calculate(...)
var sum_a = calculate(...)
var sum_b = calculate(...)
var sum_c = calculate(...)
var sum_d= calculate(...)
return
if (max('table'[category])="a",divide(_a,sum_a),if (max('table'[category])="b",divide (_b,sum_b),if (max('table'[category])="c",divide (_c,sum_c),if (max('table'[category])="d",divide (_d,sum_d),blank()))))
If I have misunderstood your meaning, please provide your pbix file without privacy information and more details with your desired output.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@frknklcsln , Try like
New Measure = Switch ( True() ,
max(Table[Category1]) ="Category1" , [Measure1],
max(Table[Category2]) ="Category1" , [Measure2],
max(Table[Category3]) ="Category1" , [Measure3],
max(Table[Category4]) ="Category1" , [Measure4] )
or
New Measure = sumx(values(Table[Category1] ) , Switch ( True() ,
max(Table[Category1]) ="Category1" , [Measure1],
max(Table[Category2]) ="Category1" , [Measure2],
max(Table[Category3]) ="Category1" , [Measure3],
max(Table[Category4]) ="Category1" , [Measure4] ) )
Sir, I need to write after the return function. I have only 1 measure which calculates for 4 different categories.
performance measure=
var _a = calculate(...)
var _b = calculate(...)
var _c = calculate(...)
var _d= calculate(...)
var sum_a = calculate(...)
var sum_b = calculate(...)
var sum_c = calculate(...)
var sum_d= calculate(...)
// I need below part
return
if category a:
divide(_a,sum_a)
if category b:
divide (_b,sum_b)
??
..
??
Hi @frknklcsln ,
Please have a try.
performance measure=
var _a = calculate(...)
var _b = calculate(...)
var _c = calculate(...)
var _d= calculate(...)
var sum_a = calculate(...)
var sum_b = calculate(...)
var sum_c = calculate(...)
var sum_d= calculate(...)
return
if (max('table'[category])="a",divide(_a,sum_a),if (max('table'[category])="b",divide (_b,sum_b),if (max('table'[category])="c",divide (_c,sum_c),if (max('table'[category])="d",divide (_d,sum_d),blank()))))
If I have misunderstood your meaning, please provide your pbix file without privacy information and more details with your desired output.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous , worked like a charm. Thank you.
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
71 | |
70 | |
38 | |
28 | |
26 |
User | Count |
---|---|
98 | |
96 | |
59 | |
44 | |
40 |