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

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

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

View solution in original post

5 REPLIES 5
RemiAnthonise
Helper V
Helper V

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.

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 others find it more quickly.

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

Anonymous
Not applicable

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

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

Cheers.

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.