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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
bo_afk
Post Patron
Post Patron

Line graph to display percentage of legend

Hi,

I have a line graph which shows the number of people by age and in the legend a separate grouping for these people. How can I display the percentage of people within that group for each age?

 

E.g. Within the whole of group 1, x % of these people are age 'Y' etc

 

Line graph PBI.JPG

 

Thanks!

afk

5 REPLIES 5
v-deddai1-msft
Community Support
Community Support

Hi @bo_afk ,

 

You can create the following measure:

 

% = DIVIDE(COUNTROWS('Table'), CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[Group])))

 

Then add it to tooltips , then you can view the % in tooltips:

Capture.PNG

 

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

 

Best Regards,

Dedmon Dai

@amitchandak , @v-deddai1-msft , thanks for you suggestions!

I also have an age slicer filter on the page so that I can see the numbers for a particular age range with the "total" value for this range only. But when I apply the filter, the formula doesn't recalculate accordingly and the "total" value is excluding the filter that I applied.

Do I need to change the formula to allow slicer filters?

Hi @bo_afk ,

 

Please use the following measure to contains filter from page:

 

% = DIVIDE (
    COUNTROWS ( 'Table' ),
    CALCULATE ( COUNTROWS ( 'Table' ), ALLSELECTED ( 'Table'[age] ) )
)

 

 

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

 

Best Regards,

Dedmon Dai

Hi @v-deddai1-msft , I gave this a go but for some reason, it's showing close to 0% or 100% for most of the ages.

amitchandak
Super User
Super User

@bo_afk , Try a measure like

divide([measure], calculate([measure],allexcept(Table[group])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.