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
Junaid11
Helper V
Helper V

Unpivot through M or ease

I have below dataset.

StudentCourse1Course2Course3Course1Course2Course1Course2Course3Course1Course2
James01/02/2019 12/08/2000Not CompliantNot CompliantYNY01/02/2021 
Jason28/09/202024/09/201911/09/2015CompliantNot CompliantNYY28/09/202224/09/2021
John17/05/201818/01/2017 Not CompliantNot CompliantNNN17/05/202018/01/2019
Jenny12/01/2021 08/09/2008Not CompliantCompliantYYY12/01/2023 
           
           
           
           
           

This data represents Student and courses they have done. First three course column shows courses and theie completeion date . Next two column shows Compliance of two courses. This goes on. I have done unpivot to see course name and their values in one column but my rows count has increased significantly. My columns have same course name but not all columns/course are repeating. Like course completion date is showing three course while compliance is showing for only two course. I want to see it as below outcome. 

JamesCourse101/02/2019Not CompliantY01/02/2021
JamesCourse2 Not CompliantN 
JamesCourse312/08/2000 Y 
JasonCourse128/09/2020CompliantN28/09/2022
JasonCourse224/09/2019Not CompliantY24/09/2021
JasonCourse311/09/2015 Y 
      

Please help the way it can be done. Either M code or any other solution.

Thanks

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Junaid11 

here is a wokaround for you . pls see the attachment below.





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

Proud to be a Super User!




View solution in original post

2 REPLIES 2
ryan_mayu
Super User
Super User

@Junaid11 

here is a wokaround for you . pls see the attachment below.





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

Proud to be a Super User!




amitchandak
Super User
Super User

@Junaid11 , In the first table which has course number, add a prefix or a suffix to give meeting what it is

 

StartDate Course1 StartDate  Course2 StartDate Course3 Compliant Course1 Compliant Course2 Status Course1 Status Course2 Status Course3 EndDate Course1 EndDate Course2

 

Now unpivot all these columns. https://radacad.com/pivot-and-unpivot-with-power-bi

 

Split by Delimiter (first only) into 2 column https://www.tutorialgateway.org/how-to-split-columns-in-power-bi/

 

the pivot again using the first column in this split

 

refer this if needed

https://kohera.be/power-bi/how-to-unpivot-twice/

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.