Forum Discussion

RemiAnthonise's avatar
7 years ago
Solved

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?

 

5 Replies

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

    • v-frfei-msft's avatar
      v-frfei-msft
      Community Support

      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