cancel
Showing results for
Search instead for
Did you mean:
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
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.
Helper V

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

 Legend Customers YearMonth A 1212144 201904 C 8585899 201904 C 5858989 201904 A 9898877 201905 A 8989988 201905 C 8989999 201905 A 9999921 201904 A 2121212 201903 B 2121212 201904 B 1414121 201904 B 2221111 201903 C 4414141 201903 C 2121212 201903 C 7111212 201902 C 7777721 201904 C 8232323 201904 C 3333212 201902 B 2121233 201905 B 1241414 201905 A 1241414 201902 A 1212121 201902 B 4444455 201904 C 2121255 201902 B 4747777 201903
Community Support

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.
Helper V

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?

Community Support

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.
Super User IV

@Samrawit21 , try like

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

oe

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

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!

## Helpful resources

Announcements

#### Happy New Year from Power BI

This is a must watch for a message from Power BI!

#### Check it Out!

Click here to read more about the December 2020 Updates!

#### Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

#### Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors