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
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])))

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.