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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
arajan111
Frequent Visitor

Unpivot calculated columns using DAX query

Hi, I have the following columns

 

 

UserCritical Use 1Critical Use 2Critical USe 3Critical UseCritical Use CalcCreative 1Creative 2Creative_CalcCreative
ABC40403033.6Adopting406050Adopting
DEF40604046.67Exploring606060Performing
GHI40202026.67Exploring206040Adopting
          

 

The columns Critical Use 1, Critical Use 2, Critical USe 3, Critical Use Calc, Critical Use, Creative 1, Creative 2, Creative_Calc, Creative are all calculated columns.

 

How can I get  a resultant tableto pivot the data above?

ABCCritical Use 1

40

ABCCritical Use 240
ABCCritical USe 330
ABCCritical Use33.6
ABCCritical Use CalcAdopting
ABCCreative 140
ABCCreative 260
ABCCreative_Calc50
ABCCreativeAdopting
6 REPLIES 6
arajan111
Frequent Visitor

The below is the original data:

UserResponse 1

 

Response 2

Response 3Response 4Response 5
ABCAdoptingPerformingAdoptingLeadingExperienced
DEFAdoptingLeadingPerformingAdoptingPerforming
GHIPerformingExperiencedLeadingPerformingAdopting

 

I have added some calculated columns to the above table:

 

UserResponse 1Response 2Response 3Response 4Response 5Critical Use 1Critical Use 2Critical USe 3Critical UseCritical Use CalcCreative 1Creative 2Creative_CalcCreative
ABCAdoptingPerformingAdoptingLeadingExperienced40304036.67Adopting608070Adopting
DEFAdoptingLeadingPerformingAdoptingPerforming40603043.33Exploring403035Performing
GHIPerformingExperiencedLeadingPerformingAdopting30806056.67Exploring308055

Adopting

 

 

 

These calculations are based on the below lookup tables:

Adopting40
Leading60
Performing30
Experienced80

 

Adopting36.67
Exploring43.37
Exploring56.67
Adopting55
Adopting70
Performing

35

 

I now need to get the table to pivot the data as follows:

 

ABCCritical Use 1

40

ABCCritical Use 240
ABCCritical USe 330
ABCCritical Use33.6
ABCCritical Use CalcAdopting
ABCCreative 140
ABCCreative 260
ABCCreative_Calc50
ABCCreativeAdopting

 

I cannot use the transform function in Query editor because the calculated columns wouldnt appear there. What would be an alternative way to get this displayed?

arajan111
Frequent Visitor

@ryan_mayu Because these columns are calculated columns, they do not appear in Query editor

could you pls provide some sample data?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Please see example below:

 

Response 1, 2, 3, 4 and 5 are original columns. The remaining columns are calculated columns. I would like to pivot the data using the calculated columns to obtaing the resultant table:

UserResponse 1Response 2Response 3

Response 4

Response 5Critical Use 1Critical Use 2Critical USe 3Critical UseCritical Use CalcCreative 1Creative 2Creative_CalcCreative
ABCAdoptingPerformingAdoptingLeadingExperienced40403033.6Adopting406050Adopting
DEFAdoptingLeadingPerformingAdoptingPerforming40604046.67Exploring606060Performing
GHIPerformingExperiencedLeadingPerforming

Adopting

40202026.67Exploring206040Adopting

how you get the critial user 1 to the end? i think based on the first 5 columns, we can't get that output. I think we need to transpose and create measures instead of the calculated columns.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




ryan_mayu
Super User
Super User

@arajan111 

you can select the first column and unpivot other columns in PQ

11.png12.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.