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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

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
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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