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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
GabrielDC
Frequent Visitor

How do I transform this table?

HI All

Sorry if this is a rookie question.

I have this table [above] with severals months and their items. I'd like to put all the months together in one single column [like the table below].

 

How can I achieve that?

 

Thanks in advance

GabrielDC_0-1664729972295.png

 

1 ACCEPTED SOLUTION

Thanks Greg, your answer inspired me to try something:

 

1) convert all fields to text type

2) concatenate each month with their respective item

GabrielDC_0-1664734324292.png

 

3) Unpivot by these concatenated columns

4) delete the month/items columns

5) Split the concatenated column

GabrielDC_1-1664734432787.png

6) Profit 🙂

 

Thanks Greg, we did this!

 

 

View solution in original post

6 REPLIES 6
CNENFRNL
Community Champion
Community Champion

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WykosUNJRMjbUt9A3MjAyArINIXxzGN9EKVYnWqm0OBFNnRGaOlOwutTcVHSFxmgKzZRiYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [region = _t, month1 = _t, item1 = _t, month2 = _t, item2 = _t]),
    #"Split to columns" = Table.ToColumns(Source),
    #"Combined tables" = let hdr = #"Split to columns"{0} in Table.Combine(List.Transform(List.Split(List.Skip(#"Split to columns"),2), each Table.FromColumns({hdr} & _)))
in
    #"Combined tables"

CNENFRNL_0-1664735582769.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Greg_Deckler
Community Champion
Community Champion

@GabrielDC See attached PBIX below sig.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks Greg, the thing is I have 12 months columns in the Table so that's going to be a lot of Tables and Appends in the Editor (which is messy already 😞 ),  is there anything that can be done with Unpivot or Transpose?

@GabrielDC Understood but that's quite possibly the worst formatting for an Excel spreadsheet to ingest into Power BI possible. If you had this:

Combined 7/31/2022 8/31/2022

usa

5 2
japan 10 3
emea 6 5
     

Then, yes, you could select "combined" column, right-click and select "Unpivot other columns". But, you don't have that.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks Greg, your answer inspired me to try something:

 

1) convert all fields to text type

2) concatenate each month with their respective item

GabrielDC_0-1664734324292.png

 

3) Unpivot by these concatenated columns

4) delete the month/items columns

5) Split the concatenated column

GabrielDC_1-1664734432787.png

6) Profit 🙂

 

Thanks Greg, we did this!

 

 

@GabrielDC Very nice!



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.