Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register 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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
11 | |
11 | |
10 | |
10 |
User | Count |
---|---|
19 | |
14 | |
13 | |
11 | |
8 |