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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
nunamhmd7
New Member

Calculate Percentage for Categorical data based on Same Year

Hi, I'm new in Power BI. Need some guidance to solve below issue.

 

nunamhmd7_0-1671818761000.png

I unable to show percentage value for each year. Can you guys help me to get the value?

 

Example calculation for Year 2022:

Female: 20/(20+12)x100% = 62.5%

Male: 12/(20+12)x100%=37.5%

 

I also need to show the value percentage in line chart as in picture above. 

 

Thank you so much.

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @nunamhmd7 ,

I created some data:

vyangliumsft_0-1672021585845.png

Here are the steps you can follow:

1. Create measure.

Measure =
var _all=SUMX(FILTER(ALL('Table'),'Table'[Year]=MAX('Table'[Year])),[Value])
var _gender=SUMX(FILTER(ALL('Table'),'Table'[Year]=MAX('Table'[Year])&&'Table'[Gender]=MAX('Table'[Gender])),[Value])
return
DIVIDE(_gender,_all)

2. Select [Measure] – Measure tools -- %.

vyangliumsft_1-1672021585851.png

3. Result:

vyangliumsft_2-1672021585853.png

 

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

View solution in original post

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @nunamhmd7 ,

I created some data:

vyangliumsft_0-1672021585845.png

Here are the steps you can follow:

1. Create measure.

Measure =
var _all=SUMX(FILTER(ALL('Table'),'Table'[Year]=MAX('Table'[Year])),[Value])
var _gender=SUMX(FILTER(ALL('Table'),'Table'[Year]=MAX('Table'[Year])&&'Table'[Gender]=MAX('Table'[Gender])),[Value])
return
DIVIDE(_gender,_all)

2. Select [Measure] – Measure tools -- %.

vyangliumsft_1-1672021585851.png

3. Result:

vyangliumsft_2-1672021585853.png

 

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

Hi thanks for your help. I manage to get it! It helps a lot

AlB
Super User
Super User

Hi @nunamhmd7 

You need to show a sample of your tables with the relevant fields and the code for the measures yo are currently using in the charts you show above

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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