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
Anonymous
Not applicable

Preparing survey data to aggregate responses based on criteria

I have 360 survey data where there was a set of 14 questions (12 multi choice and 2 free text). There is about 50 different people who the survey was conducted about - "subjects of the survey" and for each person up to 7 people "respondents" answered the 14 questions about that person. This means there are multiple different answers for each question, per "subject". 

 

I want to set up my PowerBI report so that it tells me for each "subject" of the survey and for each question, what the most common response was. I need this to be usable in visuals so that for each question, there is only one response for each person (the most common). 

 

How can I do this? I have unpivoted my data in power query so have a question and answer column. 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

hanks for the reply from Greg_Deckler , please allow me to provide another insight:

Hi, @Anonymous 
Thanks for reaching out to the Microsoft fabric community forum.

I suggest you use the List.Mode() function in Power Query, combined with pivot and unpivot operations, to achieve your needs:

1.First, delete unnecessary columns such as Responder and Responder Relationship to Subject, and select all columns except the Subject column for unpivoting.

vlinyulumsft_0-1738199278485.png

2.Next, select the "Subject" and "Attribute" columns for a group by operation, and choose the max aggregation method for easier modification.

vlinyulumsft_1-1738199278486.png

vlinyulumsft_2-1738199312472.png

3.Modify the M code for this step to better meet your needs.

= Table.Group(#"Unpivoted Columns", {"Subject", "Attribute"}, {{"Count", each List.Mode([Value]), type text}})

4.Then, select the "Attribute" column for pivoting, and choose the Count column as the value column. Remember to select "Do Not Aggregate."

vlinyulumsft_3-1738199339662.png

vlinyulumsft_4-1738199339663.png

5.For more details, please refer to the relevant documentation. I hope these steps help you achieve your goal.

List.Mode - PowerQuery M | Microsoft Learn

Please find the attached pbix relevant to the case.

 

Best Regards,

Leroy Lu

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

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Thanks for the response and guidance on posting. 

 

Below is a simplified example of how the data is exported: So you can see for one subject, there is multiple responses to the each question

 

Responder

 

Responder Relationship to SubjectSubjectSubject DeptHow would you describe their leadership style?How you describe their role in a team?What is their top skill?What is their top development area?
JohnCo-workerAmyITCoachingBrings people togetherProblem solverRecognition of peers
BenCo-workerAmyITAffiliativeKey playerBusiness accumenApproachability
SallyManagerAmyITPacesetterKey playerProblem solverCommunication
AmySelfAmyITPacesetterKey playerProblem solverCommunication
SarahCo-workerAmyITPacesetterBrings people togetherInclusvity Communication
JohnManagerSarahITCoachingKey playerCommunicationCommunication
BenCo-workerSarahITCommandingWorks in isolation Decision makingSharing information
SallyCo-workerSarahITCommandingWorks in isolation Decision makingAvailability
AmyCo-workerSarahITCommandingKey playerDecision makingStrategy 
SarahSelfSarahITPacesetterKey playerCommunicationStrategy 

 

My expected output is below (as these values were the most common response for that person) 

 

SubjectSubject deptHow would you describe their leadership style?How you describe their role in a team?What is their top skill?What is their top development area?
AmyITPacesetterKey playerProblem SolverCommunication
SarahITCommandingKey playerDecision makingStrategy

 

So then I can create visuals at the department level and have only one response for each person per question, instead of 5 in the original data. 

 

Hopefully that explains it better 🙂 

Anonymous
Not applicable

hanks for the reply from Greg_Deckler , please allow me to provide another insight:

Hi, @Anonymous 
Thanks for reaching out to the Microsoft fabric community forum.

I suggest you use the List.Mode() function in Power Query, combined with pivot and unpivot operations, to achieve your needs:

1.First, delete unnecessary columns such as Responder and Responder Relationship to Subject, and select all columns except the Subject column for unpivoting.

vlinyulumsft_0-1738199278485.png

2.Next, select the "Subject" and "Attribute" columns for a group by operation, and choose the max aggregation method for easier modification.

vlinyulumsft_1-1738199278486.png

vlinyulumsft_2-1738199312472.png

3.Modify the M code for this step to better meet your needs.

= Table.Group(#"Unpivoted Columns", {"Subject", "Attribute"}, {{"Count", each List.Mode([Value]), type text}})

4.Then, select the "Attribute" column for pivoting, and choose the Count column as the value column. Remember to select "Do Not Aggregate."

vlinyulumsft_3-1738199339662.png

vlinyulumsft_4-1738199339663.png

5.For more details, please refer to the relevant documentation. I hope these steps help you achieve your goal.

List.Mode - PowerQuery M | Microsoft Learn

Please find the attached pbix relevant to the case.

 

Best Regards,

Leroy Lu

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

 

Anonymous
Not applicable

This is great and exactly what I need - thank you so much!!

 

A quick question, what happens if someone has multiple 'most common responses', for example if 3 people say Amy is a "Key Player", 3 people say she "Brings People Together" and 1 person says she "Works in isolation" - how does it decide the most common between Key Player and Brings People Together? 

Anonymous
Not applicable

Hi, @Anonymous 
Thank you for your prompt response and for accepting my idea as the solution. Regarding your question, there is a corresponding explanation in the official documentation:

vlinyulumsft_0-1738287482523.png

vlinyulumsft_1-1738287482524.png

For more details, please refer to: 

List.Mode - PowerQuery M | Microsoft Learn

 

Best Regards,

Leroy Lu

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

Greg_Deckler
Community Champion
Community Champion

@Anonymous Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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