cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Create own stacked line chart

Hi guys,

 

I want to create my own stacked line chart. And if this is not possible (like I read in this community) I want to give the line a value for percentage of total. I know we can do this with: visual > fields > values > display value as > percentage of total. But I want to show it per period.

I've tried this measure:

Percentage of total = DIVIDE(COUNTROWS(DISTINCT(FactClient[ClientId])); COUNTROWS(DISTINCT(ALL(FactClient[ClientId])));0)

This gives me the same as the mentioned way above. What I want is the following, mind the Y-axis in image 2 (don't pay attention to the totals of each period, this is not perfectly 100%). The total of the lines in each period should be 100% togheter, not showing the percentage of the grand total. How do I solve this in my measure?

 

linechart.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
ravik4934 Member
Member

Re: Create own stacked line chart

Hi @RemiAnthonise,

 

After having look of your sample data i have modified a little bit in you dax. Its working as 100% line chart. Have a look in pbix file and revert me if any concern.

 

https://drive.google.com/file/d/1u0cVD2Wu6K75dANlAqZROY-Zabfdfcf2/view?usp=sharing

 

Best Regards,

Ravi

5 REPLIES 5

Re: Create own stacked line chart

I've tried the following measure

Percentage  =
DIVIDE(CALCULATE(DISTINCTCOUNT(FactClient[ClientId]);DimAge[AgeCategory]);CALCULATE(DISTINCTCOUNT(FactClient[ClientId])))

 

DimAge[AgeCategory] is the category for which I want to calculate the total percentage. Unfortunately, this didn't work because this field is a text, because of the category 65 - older. 

My idea was: do a distinctcount per AgeCategory based on ClientID and divide this by the total distinctcount based on ClientID. The total of this should be 100% (right?). Like I said before, this didn't work because the text field doesn't work in my filter.

 

Do you have any further ideas? My last option is trying to change all the AgeCategories but I want to avoid this.

Community Support Team
Community Support Team

Re: Create own stacked line chart

Hi @RemiAnthonise,

 

Could you please try to use ALLEXCEPT in your formula? Here the FactClient[column] should be the the column on the X-axis in your visual. If it doesn't work, kindly share your sample data to me.

 

Percentage  =
DIVIDE(CALCULATE(DISTINCTCOUNT(FactClient[ClientId]);DimAge[AgeCategory]);CALCULATE(DISTINCTCOUNT(FactClient[ClientId]),ALLEXCEPT(FactClient,FactClient[column])))

Regards,

Frank

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

Re: Create own stacked line chart

Hi Frank @v-frfei-msft

I still get the same error because of the AgeCategory filter. The X-axis is a DimDate, by the way.

Here is my pbix: https://www.dropbox.com/s/r1z1hrk73jx6di0/sample%20stacked%20line%20chart.pbix?dl=0 

Short resume: there is a stacked bar chart on my page. I want to recreate this with a line chart. Not exactly the same as the stacked bar chart or any other visual: I want to show it as a percentage of 100% for that period. See image below. Total is always 100%.

If anything is unclear, please let me know. 

 

 stacked linechart.jpg

ravik4934 Member
Member

Re: Create own stacked line chart

Hi @RemiAnthonise,

 

After having look of your sample data i have modified a little bit in you dax. Its working as 100% line chart. Have a look in pbix file and revert me if any concern.

 

https://drive.google.com/file/d/1u0cVD2Wu6K75dANlAqZROY-Zabfdfcf2/view?usp=sharing

 

Best Regards,

Ravi

Re: Create own stacked line chart

Hi @ravik4934 Ravi, thanks a lot. It works perfectly!

Cheers.