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
Anonymous
Not applicable

Percentage of total for each legend item

I am using a line visualization with multiple legend values. I want to show legends as a percentage of the total per month.

Now each legend value is displayed as a percentage of the whole.

For example, if the value for January is 2.78 % when I add a legend column which has values A, B, C the percentage is displayed as

A - 0,73 %

B- 1,71 %

C- 0,33 %, which is the percentage of the total

but I want to display it as

A- 26.4 %

B - 61.71 %

C- 11.89 %, which is the percentage of the total per month. each legend item should sum to ~100%

 

Is there a way to do this in a line chart?

Regards,

7 REPLIES 7
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

Please share some dummy data with raw table structure, then we can do test coding formula on it.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

@v-shex-msft

I am using a line chart to display the distinct count of customers with multiple legend values. I want to show the count of customers as a percentage of the total per month.
Now each legend value is displayed as a percentage of the whole.
For example, if January had a percentage of value 2.78% when I added a legend column that has A, B, C values, the percentage is displayed as
A - 0.73%
B- 1.71%
C- 0.33%, which is the percentage of the total, but I want to show it like
A- 26.4%
B - 61.71%
C- 11.89%, which is the percentage of the total per month. each legend item must add to 100%
Is there a way to do this on a line chart?

I also want to add another line chart, which sums up legend values A and B.

Is this possible to do?

Below is my sample data.

Regards,

LegendCustomersYearMonth
A1212144201904
C8585899201904
C5858989201904
A9898877201905
A8989988201905
C8989999201905
A9999921201904
A2121212201903
B2121212201904
B1414121201904
B2221111201903
C4414141201903
C2121212201903
C7111212201902
C7777721201904
C8232323201904
C3333212201902
B2121233201905
B1241414201905
A1241414201902
A1212121201902
B4444455201904
C2121255201902
B4747777201903

Hi @Anonymous,

Please check the below measure formula if it works on your side:

Measure =
DIVIDE (
    CALCULATE (
        COUNTA ( 'Table'[customers] ),
        ALLSELECTED ( 'Table' ),
        VALUES ( 'Table'[YearMonth] ),
        VALUES ( 'Table'[Legend] )
    ),
    CALCULATE ( COUNTA ( 'Table'[customers] ), ALLSELECTED ( 'Table' ) )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi 

I am tring to create a Line chart with following data. I need the output of line chart to look as per tabel 2. but it doesnt take % of COlumns - It considers % of grand total. 

 

Fields are - product name - in col/ Axis. Month in row/ legend. COunt of customer id is used. 

Appreciate your help. 

 

Reshma_Doshi_0-1628567382387.png

 

 

 

Anonymous
Not applicable

@v-shex-msft

Thank you for your reply!

I also want to add another line chart, which sums up legend values A and B.

Is this possible to do?

Hi @Anonymous,

Currently, you can't use the legend field and multiple value fields at the same time. Perhaps you can try to use R visual to manually plot the graph.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@Anonymous , try like

 

divide([measure], allexcept(Table, Table[month], Table[category]))

oe

 

divide([measure], allexcept(Table,  Table[category]))

 

Also refer https://community.powerbi.com/t5/Desktop/Percentage-of-subtotal/td-p/95390

https://youtu.be/6jTildcV2ho

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.