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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.