Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
jambopriti
Helper I
Helper I

count no of rows of top n answers in survey

jambopriti_0-1729660600326.png

Hi, I'm Power BI newbie. I'm trying to generate the card (above) to display the total of top 2 survey results. In this case 52% + 35%. Please guide how to calculate this. Thank you.

2 ACCEPTED SOLUTIONS
TomMartens
Super User
Super User

Hey @jambopriti ,

 

Please provide sample data used to create the Donut chart; otherwise, creating a calculation that honors your data is impossible. Make sure that the sample data reflects your semantic model, meaning tables, relationships, calculated columns, and measures.

Regards,
Tom



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

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

ryan_mayu
Super User
Super User

@jambopriti 

you can try this

 

Measure = DIVIDE( CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[answer] in {"Satisfied", "Very Satisfied"})),COUNTROWS('Table'))
 
11.PNG
 
pls see the attachment below
 




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

Proud to be a Super User!




View solution in original post

10 REPLIES 10
TomMartens
Super User
Super User

Hey @jambopriti ,

This DAX statement creates a measure that finds the Top 2 answers per question (assuming a slicer filters a question), calculates the share of the Top 2 answers, and finally creates a string. Please be aware that I called your sample data "pie". Of course, you have to adapt this to the name of your table.
The other thing that might be adapted is the target value:

 

 

Top 2 Box = 
var theTargetValue = 80
var noOfRowsSelected = COUNTROWS( ALLSELECTED( 'pie' ) )
var theTop2 =
    TOPN(
        2,
        ADDCOLUMNS(
            summarize(
                ALLSELECTED( 'pie' ),
                'pie'[answer]
            ),
            "c" , CALCULATE( COUNTROWS( 'pie' ) )
        ),
        [c]
    )
var theTop2_sum = 
    SUMX( theTop2 , [c]	)
return
INT(DIVIDE( theTop2_sum , noOfRowsSelected) * 100) & "% vs Target of " & theTargetValue & "%"

 

 

 

This is how it looks if the measure is used on a Card visual (next to the Donut chart):
image.png

Hopefully, this will provide what you are looking for.

Regards,

Tom



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

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Thank you TomMartens,

This one is working for one question but I'm finding difficulties in other questions.

I'm attaching the sample data and the visual what I'm trying to create. Again sorry I'm new to PowerBi and this is so dumn question. Thanks for your help!

 

in this visual the top 2 responses are not correct.

jambopriti_0-1729789905302.png

TestData:

Respondent_idquestionanswer
5751How satisfied are you with the web site experience?Very Satisfied
5751With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Very easy
5752How satisfied are you with the web site experience?Satisfied
5752With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Very easy
5753How satisfied are you with the web site experience?Very Satisfied
5753With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Very easy
5760How satisfied are you with the web site experience?Very Satisfied
5760With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Easy
5761How satisfied are you with the web site experience?Satisfied
5761With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Neither easy nor difficult
5762How satisfied are you with the web site experience?Very Satisfied
5762With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Very easy
5763How satisfied are you with the web site experience?Neutral
5763With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Easy
5764How satisfied are you with the web site experience?Very Satisfied
5764With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Very easy
5767How satisfied are you with the web site experience?Very Satisfied
5767With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Very easy
5769How satisfied are you with the web site experience?Satisfied
5769With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Difficult
5770How satisfied are you with the web site experience?Very Satisfied
5770With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Very easy
5772How satisfied are you with the web site experience?Satisfied
5772With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Neither easy nor difficult
5775How satisfied are you with the web site experience?Very Satisfied
5775With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Very easy
5776How satisfied are you with the web site experience?Satisfied
5776With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Neither easy nor difficult
5778How satisfied are you with the web site experience?Very Satisfied
5778With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Easy
5779How satisfied are you with the web site experience?Very Satisfied
5779With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Very easy
5780How satisfied are you with the web site experience?Very Satisfied
5780With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Neither easy nor difficult
5781How satisfied are you with the web site experience?Satisfied
5781With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Easy
5783How satisfied are you with the web site experience?Very Satisfied
5783With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Very easy
5785How satisfied are you with the web site experience?Satisfied
5785With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Easy
5787How satisfied are you with the web site experience?Neutral
5787With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Neither easy nor difficult
5788How satisfied are you with the web site experience?Very Satisfied
5788With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Easy
5789How satisfied are you with the web site experience?Neutral
5789With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Neither easy nor difficult
5790How satisfied are you with the web site experience?Very Satisfied
5790With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Very difficult
5791How satisfied are you with the web site experience?Very Satisfied
5791With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Easy
5792How satisfied are you with the web site experience?Neutral
5792With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Very easy
5793How satisfied are you with the web site experience?Satisfied
5793With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Easy
5795How satisfied are you with the web site experience?Very Satisfied
5795With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Easy
5796How satisfied are you with the web site experience?Satisfied
5796With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Easy
5797How satisfied are you with the web site experience?Satisfied
5797With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Neither easy nor difficult
5799How satisfied are you with the web site experience?Satisfied
5799With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Easy
5800How satisfied are you with the web site experience?Very Satisfied
5800With your intended purpose in mind, how easy or difficult was it to find / do what you were hoping  to on the site today?Very easy
5801How satisfied are you with the web site experience?Dissatisfied
5802How satisfied are you with the web site experience?Very Dissatisfied

 

Hey @jambopriti ,

 

just create a visual level filter that "filters" the question, do this for the card visual and the donut chart!

TomMartens_0-1729791100346.png


Regards,
Tom



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

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
ryan_mayu
Super User
Super User

@jambopriti 

you can try this

 

Measure = DIVIDE( CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[answer] in {"Satisfied", "Very Satisfied"})),COUNTROWS('Table'))
 
11.PNG
 
pls see the attachment below
 




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

Proud to be a Super User!




Thank You ryan_mayu.

It is working for my 2 survey questions. is there a way instead of hard coded the answer (ex: Very Satisfied & satisfied ) it can be dynamic? so if there are no value lets say satisfied then it will pick up Neutral which is next answer? Thanks you in advance.

@jambopriti 

This is exactly what my measure is doing! It finds the top 2 categories per question.
Regards,
Tom



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

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Perfect!!

Thanks Tom. It is working. Thank you so much for the guidance and solution!! 

jambopriti
Helper I
Helper I

Respondent_id,question,answer
5751,How satisfied are you with the web site experience?,Very Satisfied
5752,How satisfied are you with the web site experience?,Satisfied
5753,How satisfied are you with the web site experience?,Very Satisfied
5760,How satisfied are you with the web site experience?,Very Satisfied
5761,How satisfied are you with the web site experience?,Satisfied
5762,How satisfied are you with the web site experience?,Very Satisfied
5763,How satisfied are you with the web site experience?,Neutral
5764,How satisfied are you with the web site experience?,Very Satisfied
5767,How satisfied are you with the web site experience?,Very Satisfied
5769,How satisfied are you with the web site experience?,Satisfied
5770,How satisfied are you with the web site experience?,Very Satisfied
5772,How satisfied are you with the web site experience?,Satisfied
5775,How satisfied are you with the web site experience?,Very Satisfied
5776,How satisfied are you with the web site experience?,Satisfied
5778,How satisfied are you with the web site experience?,Very Satisfied
5779,How satisfied are you with the web site experience?,Very Satisfied
5780,How satisfied are you with the web site experience?,Very Satisfied
5781,How satisfied are you with the web site experience?,Satisfied
5783,How satisfied are you with the web site experience?,Very Satisfied
5785,How satisfied are you with the web site experience?,Satisfied
5787,How satisfied are you with the web site experience?,Neutral
5788,How satisfied are you with the web site experience?,Very Satisfied
5789,How satisfied are you with the web site experience?,Neutral
5790,How satisfied are you with the web site experience?,Very Satisfied
5791,How satisfied are you with the web site experience?,Very Satisfied
5792,How satisfied are you with the web site experience?,Neutral
5793,How satisfied are you with the web site experience?,Satisfied
5795,How satisfied are you with the web site experience?,Very Satisfied
5796,How satisfied are you with the web site experience?,Satisfied
5797,How satisfied are you with the web site experience?,Satisfied
5799,How satisfied are you with the web site experience?,Satisfied
5800,How satisfied are you with the web site experience?,Very Satisfied

TomMartens
Super User
Super User

Hey @jambopriti ,

 

Please provide sample data used to create the Donut chart; otherwise, creating a calculation that honors your data is impossible. Make sure that the sample data reflects your semantic model, meaning tables, relationships, calculated columns, and measures.

Regards,
Tom



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

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Thank you. I'm so new to the forum as well.

Here is the test data:

Respondent_idquestionanswer
5751How satisfied are you with the web site experience?Very Satisfied
5752How satisfied are you with the web site experience?Satisfied
5753How satisfied are you with the web site experience?Very Satisfied
5760How satisfied are you with the web site experience?Very Satisfied
5761How satisfied are you with the web site experience?Satisfied
5762How satisfied are you with the web site experience?Very Satisfied
5763How satisfied are you with the web site experience?Neutral
5764How satisfied are you with the web site experience?Very Satisfied
5767How satisfied are you with the web site experience?Very Satisfied
5769How satisfied are you with the web site experience?Satisfied
5770How satisfied are you with the web site experience?Very Satisfied
5772How satisfied are you with the web site experience?Satisfied
5775How satisfied are you with the web site experience?Very Satisfied
5776How satisfied are you with the web site experience?Satisfied
5778How satisfied are you with the web site experience?Very Satisfied
5779How satisfied are you with the web site experience?Very Satisfied
5780How satisfied are you with the web site experience?Very Satisfied
5781How satisfied are you with the web site experience?Satisfied
5783How satisfied are you with the web site experience?Very Satisfied
5785How satisfied are you with the web site experience?Satisfied
5787How satisfied are you with the web site experience?Neutral
5788How satisfied are you with the web site experience?Very Satisfied
5789How satisfied are you with the web site experience?Neutral
5790How satisfied are you with the web site experience?Very Satisfied
5791How satisfied are you with the web site experience?Very Satisfied
5792How satisfied are you with the web site experience?Neutral
5793How satisfied are you with the web site experience?Satisfied
5795How satisfied are you with the web site experience?Very Satisfied
5796How satisfied are you with the web site experience?Satisfied
5797How satisfied are you with the web site experience?Satisfied
5799How satisfied are you with the web site experience?Satisfied
5800How satisfied are you with the web site experience?Very Satisfied
   

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors