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
phaum1967
Resolver I
Resolver I

Unpivot header

Hi everyone,

I have serveral csv files that I want to transform.

I want to create a function but I m unable to define how I can Unpivot all my files:

Capture d'écran 2017-12-18 à 07.15.03.png

The first row contains period of time from column4 to ColumnX (it depends on the csv)

For each csv file, Periods could be different. In this screenshot I have 201401, 201402,... But sometimes I will have 201301,201203....

 

When in my function, i'm unpivoting The code is :

#"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Column1", Int64.Type}, {"NoClient", Int64.Type}, {"NoProduit", Int64.Type}, {"Values", type text}, {"201401", type text}, {"201402", type text}, {"201403", type text}, {"201404", type text}, {"201405", type text}, {"201406", type text}, {"201407", type text}, {"201408", type text}, {"201409", type text}, {"201410", type text}, {"201411", type text}}),

#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type1", {"Column1", "NoClient", "NoProduit", "Values"}, "Attribute", "Value")

 

But when I want to use my function, I have this error : Expressio.error: the column 201401 of the table was not found.

 

Of course due to periods which are not the same...

 

I think the solution will be for me to add column 4 to x in the same colum (period) and transpose the column Type ?

Thanks for helping

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Perhaps try this for your Promoted Headers:

 

#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),

 

 


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Super User
Super User

Perhaps try this for your Promoted Headers:

 

#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),

 

 


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.