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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
firefly3224
Frequent Visitor

How to create dynamic percent measure

Updated: In the example below, I'm trying to visualize racial composition by year. When race slicers are applied, the correct % are shown. However, the % for all Asians in 2014 is incorrect.

 

How do I create a dynamic percent measure, so that the correct % shows even when no slicers are used?

 

Dataframe:

firefly3224_1-1614356824617.png

 

 

firefly3224_0-1614356797396.png

 

 

 

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

@firefly3224 

You are going to need to calulate the absolute values from which the % derives (since you have more than one row per year asians and to calculate over totals). So, what is the % of? is it the % of total headcount? If so, you need to calculate the total headcount  as a new calculated column in the data table

 

total headcount = DIVIDE( table[Headcount], table [percent])

 

and then calculate the % as a measure to use in the visuals:

 

% of total headcount =
VAR headcount =
    SUM ( Table[ Headcount] )
VAR TotalHC =
    SUM ( Table[total headocunt] )
RETURN
    DIVIDE ( headcount, TotalHC )

 

 

 

 

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Hi  @firefly3224 ,

Here are the steps you can follow:

1. Create measure.

divide =
var _1=CALCULATE(SUM('Table'[Count]),ALLEXCEPT('Table','Table'[Year],'Table'[Race]))
var _2=CALCULATE(SUM('Table'[Headcount]),ALLEXCEPT('Table','Table'[Year],'Table'[Race]))
return
DIVIDE(_1,_2)

2. Result.

v-yangliu-msft_0-1614586683045.png

 

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

PaulDBrown
Community Champion
Community Champion

@firefly3224 

You are going to need to calulate the absolute values from which the % derives (since you have more than one row per year asians and to calculate over totals). So, what is the % of? is it the % of total headcount? If so, you need to calculate the total headcount  as a new calculated column in the data table

 

total headcount = DIVIDE( table[Headcount], table [percent])

 

and then calculate the % as a measure to use in the visuals:

 

% of total headcount =
VAR headcount =
    SUM ( Table[ Headcount] )
VAR TotalHC =
    SUM ( Table[total headocunt] )
RETURN
    DIVIDE ( headcount, TotalHC )

 

 

 

 

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






amitchandak
Super User
Super User

@firefly3224 , Make sure you have a year column, Try a measure like

 

divide(sum(table[headcount]), calculate(sum(Table[headcount]), filter(allselected(Table), Table[Year] =max(Table[Year]))))

Thanks @amitchandak, I've made the corrections and will tinker with the solution (new user here!)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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