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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
gancw1
Resolver II
Resolver II

Unpivot table

I have a quiz result in the following format

 

NameidQ11Q21
Staff A102TRUE1FALSE0
Staff B222FALSE0FALSE0
Staff C312TRUE1TRUE1

 

How do I unpivot the table to this format ?

 

NameidQuestionAnsScore
Staff A102Q1 TRUE1
Staff A102Q2 FALSE0
Staff B222Q1 FALSE0
Staff B222Q2 FALSE0
Staff C312Q1 TRUE1
Staff C312Q2 TRUE1
4 REPLIES 4
gancw1
Resolver II
Resolver II

My example was not very clear.  The '1' label is the maximum score possible for the question and true or false answer does not equal to 1 or 0 score

 

Input 

NameidQ1Max Score  Q2Max Score
Staff A  102A  1C  0
Staff B  222C  0B  1
Staff C  3120A  0

 

The desired output

Name        id         QuestionAnsScore
Staff A  102Q1 A  1
Staff A  102Q2 C  0
Staff B  222Q1 C  0
Staff B  222Q2 B  1
Staff C  312Q1 B  0
Staff C  312Q2 A  1
PoweredOut
Resolver I
Resolver I

In Power Query, highlight the Name ID column and choose unpivot other columns

HotChilli
Super User
Super User

The columns with 0 and 1 in are redundant so you could remove those.

Then Select the first 2 columns and Unpivot others.

If you want, you can add a custom column to represent TRUE/FALSE as 1/0

The true/false has no relation to the 1/0. It just happened that for these questions the true answer is the correct answer

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.