Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

% of total as measure

Hi there! 

 

I have some data that looks like this:

 

PurchaserFlavorCount
TiffanyVanilla20
TiffanyChocolate50
TiffanyStrawberry30

 

I need to create a measure for each of the flavors to produce an output that looks like this:

 

PurchaserVanilla (%)Chocolate (%)Strawberry
Tiffany20%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!! 

1 ACCEPTED SOLUTION
AUaero
Responsive Resident
Responsive Resident

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.

View solution in original post

1 REPLY 1
AUaero
Responsive Resident
Responsive Resident

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.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.