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
ninos-shiba
Resolver I
Resolver I

How to unpivot and pivot multiple columns into their own groups with their respective rows?

I have a table in this structure (from a SharePoint List):

Row IDDateEvaluator NameQuestion 1Question 2Question 3Question 1 CommentsQuestion 2 CommentsQuestion 3 CommentsQuestion 1 PointQuestion 2 PointQuestion 3 PointQuestion 1 Missed ReasonsQuestion 2 Missed ReasonsQuestion 3 Missed Reasons
19/18/2020JakeGoodBadGoodComments hereComments hereComments here313Reason 1, Reason 2Reason 2Reason 2, Reason 4
29/19/2020MaryBadGoodGoodComments hereComments hereComments here133Reason 1Reason 2Reason 3
39/23/2020WilliamNeutralNeutralGoodComments hereComments hereComments here223Reason 2Reason 2Reason 2
49/23/2020JakeBadGoodBadComments hereComments hereComments here131Reason 3, Reason 4Reason 4Reason 1

 

 

I'd like to transform it (unpivot, pivot, etc.) to obtain this result (for example):

 

Row IDDateEvaluator NameQuestionResponseCommentsPointsMissed Reasons
   Question 1GoodQuestion 1 Comments  
   Question 1    
   Question 1    

 

Basically, I'd like to group all the question columns, comments columns, points columns, and reason columns into their own respective columns with the corresponding rows.

 

Is there a way to transform my data to get that end result?

1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

You will need to find the delimiter between Question 1 and Comments, Points, etc.

For example, if you have Question 1: Comments
Question 1: Points
Question 1: Missed Reasons

If you don't have that delimiter, you can use a conditional column to look for text that contains Missed Reasons, Point, Comments and use that to determine which part of the question it answers.

Please see the attached file for reference. I will upload it under the signature.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

1 REPLY 1
AllisonKennedy
Super User
Super User

You will need to find the delimiter between Question 1 and Comments, Points, etc.

For example, if you have Question 1: Comments
Question 1: Points
Question 1: Missed Reasons

If you don't have that delimiter, you can use a conditional column to look for text that contains Missed Reasons, Point, Comments and use that to determine which part of the question it answers.

Please see the attached file for reference. I will upload it under the signature.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

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.