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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
RandyPBI-BH
New Member

Unpivot only selected columns - Dymanic Names

Hello,

 

I have Financial P&L Matrix,  human interface friendly where Rows are the accounts , columns names are actual/(monthyear) or Forecast/(monthyear), and the values in cell are the finacial values. database is something like this:

countryAccountActual/Jan2023Actual/Feb2023Forecast/Mar2023Forecast/Apr2024Forecast/May2025Forecast/Jun2026
United StatesTotal Revenue100010501000105010001050
United StatesTotal Cost500600500600500600
FranceTotal Revenue100011001000110010001100
FranceTotal Cost700800700800700800

 

I do unpivot Only selected columns from the functions and the DAX formula goes like this:

 

Table.Unpivot(#"Expanded romeveheader1", {"Actual/Jan2023", "Actual/Feb2023", "Forecast/Mar2023", "Forecast/Apr2023", "Forecast/May2023", "Forecast/Jun2023"},"Attribute","Value")

 

Question/challenge:

 

At the beggining of April 2023 when the account results are available, the column "Forecast/Mar2023" name is going to change to "Actual/Mar2023"

 

so instead of coming to powerquery and change the column name every month, is there a way that I can unpivot with dymanic column names?

 

Thanks in advance

 

1 ACCEPTED SOLUTION
jgordon11
Resolver II
Resolver II

Assuming romeveheader1 is not a typo (although removeheader1 seems more likely) and the first two columns are the only ones not unpivoting:

 

Table.Unpivot(#"Expanded romeveheader1", List.Skip(Table.ColumnNames(#"Expanded romeveheader1"),2),"Attribute","Value")

View solution in original post

2 REPLIES 2
RandyPBI-BH
New Member

Thanks for the solution!

jgordon11
Resolver II
Resolver II

Assuming romeveheader1 is not a typo (although removeheader1 seems more likely) and the first two columns are the only ones not unpivoting:

 

Table.Unpivot(#"Expanded romeveheader1", List.Skip(Table.ColumnNames(#"Expanded romeveheader1"),2),"Attribute","Value")

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors