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
NB3
Helper III
Helper III

Percentage of positive answers based on respondents

Hi everyone,

 

I'm stuck with this data I have based on a study we did.

 

To put it in a nutshell let's say we have 10 people who answered our questions.

 

One of the questions had 5 answers for which they had to say Yes/No/Idk

 

What we want is find the percentage of "YES" for each possible answer to this question.

 

Each answer is in a column so right now I have a main table with and Id for each person.

And another pivoted table to have all the possible answers to this question in the "Attribute" column

And the answer given for each attribute (Yes/No/Idk) in the "Value" column.

 

I'd like to know if there is a Dax formula or different steps of Dax formulas to calculate the percentage of Yes for each answer for each person.

 

Example:

Q1 (x 10 people)

 Proposition 1 - Yes/No/Idk

 Proposition 2 - Yes/No/Idk

 Proposition 3 - Yes/No/Idk

 Proposition 4 - Yes/No/Idk

 

Thanks everyone for the help,

 

Cheers,

3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi @NB3 ,

Please try to create a similar measure as below:

percentage=
DIVIDE (
    CALCULATE (
        DISTINCTCOUNT ( 'table'[id] ),
        FILTER ( 'table', 'table'[value] = "Yes" )
    ),
    DISTINCTCOUNT ( 'table'[id] )
)

If the above measure is not appliable for your scenario, please provide some sample data about question and attribute table and your actual expected result. Thank you.

Best Regards

Rena

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

@v-yiruan-msft the measure returns "100%" for all of the subcategories of the question,

 

Capture.PNG

 

This what my dataset looks like. 

ID for each person and a,b,c,d,e for each possible answer to question 4 (1=Yes, 2=No, 99=Doesn't know)

 

Thanks,

Hi @NB3 ,

You can create a slicer with propositions fields, then create a measure to calculate the percentage of positive answer per proposition(just like below screen shot).

 

percentage of Q4 = 
DIVIDE (
    CALCULATE (
        DISTINCTCOUNT ( 'Question'[ID] ),
        FILTER ( 'Question', SWITCH(SELECTEDVALUE('Propositions'[Proposition]),"Q4a",'Question'[Q4a], "Q4b",'Question'[Q4b], "Q4c",'Question'[Q4c], "Q4d",'Question'[Q4d],"Q4e",'Question'[Q4e]) = 1 )
    ),
    DISTINCTCOUNT ('Question'[ID] )
)

 

percentage.JPG

Best Regards

Rena

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

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.