cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Junaid11
Helper IV
Helper IV

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/



New Power BI Features
Datamarts: https://youtu.be/8tskWsJTEpg
Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin !! Proud to be a Super User!
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
!! Subscribe to my youtube Channel !!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors