Forum Discussion

lisago1978's avatar
lisago1978
Helper III
6 years ago
Solved

Calculating % category using same dynamic sum as denominator

I am trying to figure out how to create a % for a category using the same denominator across all rows

 

Table 1 has the calculated measure that is a summation of the No Health variable (e.g. the denominator for category %)

 

Total= Calculate(Sum('Table 1'[No Health])

 

Entry IDTypeNo Health
1Public1
2Business1
3Public1
4Health0
5Health0
6Business1

 

Next, I need to get a count (Entry ID) in Table 2 for each category 

 

ID_COUNT= CALCULATE(COUNT('Table 2'[Entry ID]))

 

Entry IDCategory
1A
1B
1C
2B
2C
3A
3C
4B
4C
5A
5C
6B
6C

 

Finally, I need to be able to use the numerators and denominator to create a % by category (Table 3)

 

% Category= CALCULATE(DIVIDE([Total,[ID_Count], ALL('Table 2'[Category])))

 

CategoryCount% Category
A250%
B375%
C4100%
D00%
  • Hi , lisago1978 

    Just need to change your measure as below:

    % Category = CALCULATE(DIVIDE([ID_Count],[Total]))

     

    pbix attached

     

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

2 Replies

  • lisago1978 

    Can you share the tables where I can see a clear relationship?
    And, explain how you calculated the following please:

     

    Count and % Category in the last table

    ________________________

    Did I answer your question? Mark this post as a solution, this will help others!.

    I accept KUDOS 🙂

    YouTube, LinkedIn

     

     

     




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

    Hi , lisago1978 

    Just need to change your measure as below:

    % Category = CALCULATE(DIVIDE([ID_Count],[Total]))

     

    pbix attached

     

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