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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
jcastr02
Post Prodigy
Post Prodigy

Transform / Unpivot Columns

Hello I have below 4 columns with data but need to unpivot somehow to get desired results.  I 've tried all the possible unpivot actions but I can't get it work.  Any thoughts?

 

Current:

StoreTimeframeAverage Flu VolumeAvg Rx Volume
123Winter 20230.896696428192
45Winter 20231.805026641183
80Winter 20231.368312214168
20Winter 20230.483249572166
50Winter 20231.010349568130
60Summer 20240.756196089117.75
70Summer 20241.674370276312.75
80Summer 20241.257343793182

 

Desired:

StoreWinter 2023 - Average Flu VolumeWinter 2023 - Avg Rx VolumeSummer 2024 - Average Flu VolumeSummer 2024 - Avg Rx Volume
1230.896696428192  
451.805026641183  
801.368312214168  
200.483249572166  
501.010349568130  
60  0.756196089117.75
70  1.674370276312.75
80  1.257343793182
1 ACCEPTED SOLUTION

Hi @jcastr02 It is not an efficient way to work, but yes it is possible

Ritaf1983_1-1702407228431.png

 

It is a lot of steps :

You need to duplicate the tables twice, to pivot one table for average Rx

Second for Avg Rx and to merge these pivoted tables.

The updated pbix is attached, you can follow my steps.

**I didn't format column names, you can modify them according to your needs.

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

4 REPLIES 4
Ritaf1983
Super User
Super User

Hi @jcastr02 
If it is for visualization, you just need to use a Hierarchical matrix :

Ritaf1983_0-1702405264316.png

Note that I added conditional column from PQ, for sorting in the needed order these columns

Ritaf1983_1-1702405350424.pngRitaf1983_2-1702405378459.png

Pbix is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Thanks @Ritaf1983 I am needing to add it to a table visual that has other items tied to it - would there be a way to transform it on back end - so I can just pull the below in as columns to the visual?

Winter 2023 - Average Flu VolumeWinter 2023 - Avg Rx VolumeSummer 2024 - Average Flu VolumeSummer 2024 - Avg Rx Volume

Hi @jcastr02 It is not an efficient way to work, but yes it is possible

Ritaf1983_1-1702407228431.png

 

It is a lot of steps :

You need to duplicate the tables twice, to pivot one table for average Rx

Second for Avg Rx and to merge these pivoted tables.

The updated pbix is attached, you can follow my steps.

**I didn't format column names, you can modify them according to your needs.

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

That worked, Thank you 🙂

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

Check out the May 2025 Power BI update to learn about new features.

May 2025 Monthly Update

Fabric Community Update - May 2025

Find out what's new and trending in the Fabric community.