cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper V
Helper V

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,

6 REPLIES 6
Highlighted
Super User IV
Super User IV

@Samrawit21 , 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



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Highlighted
Community Support
Community Support

Hi @Samrawit21,

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.
Highlighted

@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
Highlighted

Hi @Samrawit21,

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.
Highlighted

@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?

Highlighted

Hi @Samrawit21,

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.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Community Conference

Microsoft Power Platform Communities

Check out the Winners!

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors