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
redzum
Frequent Visitor

Reshape data to simplify visual plot

Hi All,

 

I'm new here and beginner in PBI. I have data originally with 5 columns and to be manipulated for visuals (line & bar chart). I have to introduce new column to re-shape & calculate the different between subsequent event of data as compared to 1st data available for every unit ID. The new column is to be introduced for visual plot (column F untill K). I attached here the perfect data arrangement (in excel format) that i need  to do in PBI. 

 

data excel.png

 

Question here what is DAX formula that i can i apply to have value at firstdate for "PCP subsidence", "SCP Subsidence" and "CCP Subsidence" to be in new column of "PCP_1", "SCP_1" and "CCP_1" for every unique ID.  The reason of sorting like this is to simplify the calculation of subseqeunt event for unique ID with first value on the firstdate. 

 

Thank you in advance for any feedback & help.

 

Chart 2.png

1 ACCEPTED SOLUTION

Unpivoting as a principle should not be impacted by how many columns you have. I don't think you need to use VBA in preference to Power Querr



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

View solution in original post

4 REPLIES 4

I have produced a small sample workbook for you.

https://www.dropbox.com/s/cwcgduqi7efdath/reshape.pbix?dl=1

 

I unpivoted the data into a different shape that makes the code more efficient.  Take a look and see if you can work out how it works. Let me know if you have questions.


Matt



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Hi Matt,

 

Thanks for help, really appreciate it. Actually original file are with many columns with other parameters more than what i provided before, see as attached. That is the reason why i need to find a way to re-shape the data at the 1st place. Perhaps i need to reshape the data using VBA in excel prior import to PBI if DAX is not possible to do it?

 

Capture2.JPG  

 

Redzuan

Unpivoting as a principle should not be impacted by how many columns you have. I don't think you need to use VBA in preference to Power Querr



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Hi Matt,

 

I managed to automate by using unpivot in data query. This is what i need. Thanks for the solution. Awesome!

 

 

Thanks

Redzuan

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.