Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Getting percent on row while counting some columns

I have a situation where I have a table with individual feedback scores and want to produce a matrix showing rating groups and their percentage of the  year's total feedback but I don't want to add counts for a 0 score (meaning the question wasn't answered). I have looked at quite a few examples that seem similar but not quite the same. From looking at examples in this community, I have tried a few things I've seen and I have it close to correct but I think I am not doing it right. 

DateCustomerFeedback score
12/02/2019ABC5
12/05/2019SDF7
04/20/2020FDR0
05/21/2020GTR6
06/12/2020EWR2
07/23/2021QWE7
08/21/2021FDS1
06/25/2022ABC0
07/12/2022HJK5

 

this would then consolidate to (counts shown):

Year01-56-7Total
20190112
20201113
20210112
20221102

What I would like to add is a percentage for the rating groups of 1-5 and 6-7 of their amounts of the total that doesn't include counts in the 0 column. For example, the first row both 1-5 and 6-7 would be 50%. 2020 it would also be 50% because the total count would be 2 (don't include the 0 column). 2022 would be 100% for the rating group of 1-5. 

 

I created two measures: 

# of non-zero feedbacks = 

CALCULATE(
COUNTROWS( 'Customer Feedback' ),
ALLEXCEPT( 'Customer Feedback', 'Customer Feedback'[score] ), 'Customer Feedback'[score] > 0
)

 

% of non-zero = count('Customer Feedback'[score])/ 'Customer Feedback'[# of Non-zero feedbacks]
 
Then I created a matrix that shows (this doesn't match the data above):

 

What it seems to do is correctly show on the very bottom total line (the 83% for 6-7 rating should be 83.3%, so it is probably just format but correct number) but for 2022, it should be 86.7% and not 5% (26 / 30). The 0 column doesn't really need a percentage because it isn't included in response rating percentages - so it really should be 0% and then the 1-5 and 6-7 percentages should be there. 

I had laid it out this way because it seemed easy to view the counts and percentages, but it can be changed to show the percentage next to the appropriate columns if making the calculations work is easier. 

 

Can someone help me figure the right measures and how to make the matrix to present this?

  • Hi Anonymous 

     

    I got this!

    Percentage Measure = 
    VAR Numerator =
        CALCULATE(
            [FeedbackCount],
            'Customer Feedback'[feedback score] <> 0
        )
    VAR Denominator =
        CALCULATE(
            [FeedbackCount],
            CALCULATETABLE(
                'Customer Feedback',
                'Customer Feedback'[feedback score] <> 0,
                REMOVEFILTERS('Customer Feedback'[feedback score (groups)])
            )
        )
    RETURN
    
    DIVIDE(
        Numerator,
        Denominator,
        BLANK()
    )

     

     

  • Anonymous try another measure...should be something like this (maybe???)

    CALCULATE(
    	[The Measure I Gave You Earlier],
    	[Group/bin] = "6-7"
    )

     

17 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    ok so i stripped out all colummns except a couple but kept the full records so I can figure out what they should be easier. 🙂  I uploaded it to google drive so hopefully this works... https://docs.google.com/spreadsheets/d/1kVmuUrrEvUIbjOnYPh9YOeP4WoE42goL/edit?usp=sharing&ouid=109249049242950252834&rtpof=true&sd=true 

    I was going to copy up also my trial PBI file but it kept showing a path with some restricted info in it for my data source so I don't think I can upload it - couldn't get it to point to the Google drive file. 

     

    For the 6-7 column the percentage by year should be:

    2022 = 86.7%

    2021 = 84.8%

    2020 = 79.8%

    2019 = 86.2%

    total of all years = 83.3%

     

    The 2-5 (guess I have no 1's lol) would be the difference between 100 and the 6-7 percentages....

     

    I used groups on the feedback score to provide the groupings...

    • littlemojopuppy's avatar
      littlemojopuppy
      Community Champion

      Hi Anonymous 

       

      I got this!

      Percentage Measure = 
      VAR Numerator =
          CALCULATE(
              [FeedbackCount],
              'Customer Feedback'[feedback score] <> 0
          )
      VAR Denominator =
          CALCULATE(
              [FeedbackCount],
              CALCULATETABLE(
                  'Customer Feedback',
                  'Customer Feedback'[feedback score] <> 0,
                  REMOVEFILTERS('Customer Feedback'[feedback score (groups)])
              )
          )
      RETURN
      
      DIVIDE(
          Numerator,
          Denominator,
          BLANK()
      )

       

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        thanks!  I would've never gotten that....and I think I mostly understand what you did. lol

  • littlemojopuppy's avatar
    littlemojopuppy
    Community Champion

    Hi Anonymous 

     

    Try this...

    Average Measure =
    AVERAGEX(
    	FILTER(
    		'Customer Feedback',
    		'Customer Feedback'[score] > 0
    	),
    	'Customer Feedback'[score]
    )

    Hope this helps!

    • Anonymous's avatar
      Anonymous
      Not applicable

      do I replace the percentage one I have with this one or do I add it somewhere in addition?