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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Unpivot data into multiple columns

Hello,

 

I have a data set with the following structure (columns)

 

Attribute  SalesYear1 SalesYear1 SalesYear1  CostYear1 CostYear2 CostYear3

 

I would like to transform this into the following structure (columns)

Attribute Year Sales Costs

 

I think it would be staright forward without the cost column. However, I don't know how to unpiviot into more than two rows.

 

Thank you in advance for any help

1 ACCEPTED SOLUTION

Duplicate the query.

In one, unpivot the Sales columns and remove the cost columns.

In the other, unpivot the Costs and remove the sales columns.

In each query, alter the data so you have Year in a column by itself

'Merge as New' the two queries on  Year and Division (Inner Join).

Expand and tidy as appropriate.

View solution in original post

4 REPLIES 4
HotChilli
Community Champion
Community Champion

Can you provide some sample data please

Anonymous
Not applicable

This is an example: I can unpivot the three sales columns into two columns (year & sales Value). However; iwould like to have three columns (year, sales value & cost value)powerbi1.PNGpowerbi2.PNG

Duplicate the query.

In one, unpivot the Sales columns and remove the cost columns.

In the other, unpivot the Costs and remove the sales columns.

In each query, alter the data so you have Year in a column by itself

'Merge as New' the two queries on  Year and Division (Inner Join).

Expand and tidy as appropriate.

Anonymous
Not applicable

This worked out! Thank you for your time & effort to look into this! I appreciate your help!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

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

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.