Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hi there!
I have some data that looks like this:
Purchaser | Flavor | Count |
Tiffany | Vanilla | 20 |
Tiffany | Chocolate | 50 |
Tiffany | Strawberry | 30 |
I need to create a measure for each of the flavors to produce an output that looks like this:
Purchaser | Vanilla (%) | Chocolate (%) | Strawberry |
Tiffany | 20% | 50% | 30% |
I know I can achieve this by using matrix, but I'm looking to add a bunch of other measures to one table.
Thanks so much!!
Solved! Go to Solution.
Try this:
% Vanilla to Total =
VAR Flavor = "Vanilla"
VAR FlavorValue =
CALCULATE(
SUM(TestData[Count]),
TestData[Flavor] = Flavor
)
VAR TotalValue =
CALCULATE(
SUM(TestData[Count]),
ALL(TestData),
VALUES(TestData[Purchaser])
)
RETURN
DIVIDE(FlavorValue, TotalValue)
Use this code to create measures for chocolate and strawberry by changing value of the Flavor variable.
Please accept this as a solution if it solves your problem.
Try this:
% Vanilla to Total =
VAR Flavor = "Vanilla"
VAR FlavorValue =
CALCULATE(
SUM(TestData[Count]),
TestData[Flavor] = Flavor
)
VAR TotalValue =
CALCULATE(
SUM(TestData[Count]),
ALL(TestData),
VALUES(TestData[Purchaser])
)
RETURN
DIVIDE(FlavorValue, TotalValue)
Use this code to create measures for chocolate and strawberry by changing value of the Flavor variable.
Please accept this as a solution if it solves your problem.
User | Count |
---|---|
15 | |
11 | |
6 | |
6 | |
5 |
User | Count |
---|---|
29 | |
17 | |
11 | |
7 | |
5 |