Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Need help getting to % on filtered data

I think there is a simple answer to what I'm trying to do, but I've been looking at it too long and can't see the forest through the trees now.  Given a table of survey responses, using the CARD visualization, I simply want to display the % of satisfied survey responses.  I have played with measures, but I couldn't get it to work in concert with the slicers (assuming because the measures I tried used Calculate with a filter which I think bypasses the slicers). 

 

I have attached a test pbix file here to illustrate what I'm trying to do:  Test.pbix

 

 

 

Thank you!

 

Dan

  • I would solve by creating TWO new columns in your table. 

     

    Dissatisfied = IF(SurveyResponses[Satisfaction]="Dissatisfied",1,0)
    Satisfied = IF(SurveyResponses[Satisfaction]="Satisfied",1,0)
     
    I would then create these measures
     
    Total Dissatisified = SUM(SurveyResponses[Dissatisfied])
    Total Satisfied = SUM(SurveyResponses[Satisfied])
    Total Survey = [Total Satisfied]+[Total Dissatisified]
    %Satisfied = [Total Satisfied]/[Total Survey] "You need to format this as a percentage"
     
    After you do all of the above then drag the %Satisified measure into the Values field for your card. 
     
    That would be my approach, your mileage may vary. 
     
     

     

  • Hi Dan,

     

    Try this measure.

     

    % of Satisfied Responses =
    var satisfiedResponses = CALCULATE(COUNT(SurveyResponses[Satisfaction]), LOWER(SurveyResponses[Satisfaction]) = "satisfied")
    var totalResponses = CALCULATE(COUNT(SurveyResponses[Satisfaction]))
    RETURN IF(ISBLANK(satisfiedResponses), 0, CALCULATE(DIVIDE(satisfiedResponses, totalResponses,0)))
     
    And with this field selected, go to Modeling tab, change the Formatting to %; set the decimal places per your need.
     
     
    Regards,
    Tarun

    Did I answer your question? Mark my post as a solution!

4 Replies

  • Hi Dan,

     

    Try this measure.

     

    % of Satisfied Responses =
    var satisfiedResponses = CALCULATE(COUNT(SurveyResponses[Satisfaction]), LOWER(SurveyResponses[Satisfaction]) = "satisfied")
    var totalResponses = CALCULATE(COUNT(SurveyResponses[Satisfaction]))
    RETURN IF(ISBLANK(satisfiedResponses), 0, CALCULATE(DIVIDE(satisfiedResponses, totalResponses,0)))
     
    And with this field selected, go to Modeling tab, change the Formatting to %; set the decimal places per your need.
     
     
    Regards,
    Tarun

    Did I answer your question? Mark my post as a solution!
  • I would solve by creating TWO new columns in your table. 

     

    Dissatisfied = IF(SurveyResponses[Satisfaction]="Dissatisfied",1,0)
    Satisfied = IF(SurveyResponses[Satisfaction]="Satisfied",1,0)
     
    I would then create these measures
     
    Total Dissatisified = SUM(SurveyResponses[Dissatisfied])
    Total Satisfied = SUM(SurveyResponses[Satisfied])
    Total Survey = [Total Satisfied]+[Total Dissatisified]
    %Satisfied = [Total Satisfied]/[Total Survey] "You need to format this as a percentage"
     
    After you do all of the above then drag the %Satisified measure into the Values field for your card. 
     
    That would be my approach, your mileage may vary. 
     
     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you, this was the solution I chose to move forward with, even though the other solution worked too.  Thanks a bunch!

    • Anonymous's avatar
      Anonymous
      Not applicable

      I tested it and it works great.  Thank you!