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
travbum
Advocate I
Advocate I

Best way to deal with unpivoting data

I'm using this face data source to learn about unpivoting data:

 

UserIDQuestion2Question3_1Question3_2Question1_1Question1_2Question1_3
0TRUE09Agree a lotAgreeNeutral
1FALSE59DisagreeAgreeAgree
2TRUE678Agree a lotDisagree a lot 
3FALSE32DisagreeAgree a lotAgree a lot
4TRUE93 DisagreeDisagree
5TRUE95AgreeDisagreeDisagree
6TRUE07Agree a lot Neutral
7FALSE567Agree a lotAgreeNeutral
8FALSE673DisagreeAgree 
9 39 Disagree a lotDisagree
10FALSE99Agree a lotAgree a lotAgree a lot
11 95DisagreeDisagreeDisagree
12TRUE867Disagree Disagree
13 23AgreeDisagree a lotAgree
14TRUE39DisagreeDisagreeDisagree
15 59Agree a lotAgree a lotAgree a lot
16TRUE78 Disagree 
17FALSE834Agree a lotAgree a lotAgree a lot

 

Untitled.png

 

First issue I realized is that unpivoting removes any null cells so I realize I have to change from null to some other value to stop this from happening. 

 

Second issue, as stuff is unpivoted, there are many near duplicates such as in the first three rows of the Power BI Screenshot above. What is the best way to deal with this? 


Anything else I'm missing or should be aware of? 

1 ACCEPTED SOLUTION

@travbum

 

With this unpivoting table, you can create another summarize table with following DAX formula.

 

Table2 = 
    SUMMARIZECOLUMNS ( Table1[UserID], Table1[Question3], Table1[Question3 Answer] )

Best way to deal with unpivoting data_2.jpgBest way to deal with unpivoting data_1.jpg

 

Best Regards,

Herbert

View solution in original post

3 REPLIES 3
v-haibl-msft
Employee
Employee

@travbum

 

The first one should just be an expected action for unpivoting with Power Query. If we want to keep the null cells, we can replace them with some other values do not exist and change back to null after unpivot.

 

For the second one, why do you think it is an issue? They are different rows for different questions and answers. What is your expected output here?

 

Best Regards,

Herbert

@v-haibl-msft - As far as the second question, if I wanted to do a sum of the values in column "Question 3 Answer", I would get 37 (0 + 0 + 0 + 9 + 9 + 9 + 5 + 5) instead of the real value of 14 (0 + 9 + 5). 

@travbum

 

With this unpivoting table, you can create another summarize table with following DAX formula.

 

Table2 = 
    SUMMARIZECOLUMNS ( Table1[UserID], Table1[Question3], Table1[Question3 Answer] )

Best way to deal with unpivoting data_2.jpgBest way to deal with unpivoting data_1.jpg

 

Best Regards,

Herbert

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.