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
esquiveljc
Frequent Visitor

How to change column names by row values from another column?

Hello,
I have the column names in rows. Let me explain: Column1 must be replaced by the only value in Agg1 therefore "Country", Column2 must be replaced by the only value in Agg2 therefore "Cities" and so on.

 

Column1Column2Column3Agg1Agg2Agg3
United StatesMiami483395CountryCitiesPopulation
United StatesNew York8804190CountryCitiesPopulation
United StatesLos Angeles3971883CountryCitiesPopulation
United StatesChicago2720546CountryCitiesPopulation
United StatesSeattle737015CountryCitiesPopulation
United StatesSan Francisco864816CountryCitiesPopulation
United StatesBoston696959CountryCitiesPopulation
United StatesHouston2296224CountryCitiesPopulation
United StatesPhiladelphia1603797CountryCitiesPopulation
United StatesDallas1300092CountryCitiesPopulation
United StatesPhoenix1608139CountryCitiesPopulation
CanadaVancouver600000CountryCitiesPopulation
CanadaMontreal1600000CountryCitiesPopulation
CanadaCalgary1019942CountryCitiesPopulation
CanadaQuebec528595CountryCitiesPopulation
CanadaToronto2600000CountryCitiesPopulation
CanadaWinnipeg632063CountryCitiesPopulation
CanadaOttawa812129CountryCitiesPopulation
CanadaEdmonton712391CountryCitiesPopulation
CanadaHalifax359111CountryCitiesPopulation
CanadaHamilton519949CountryCitiesPopulation
CanadaRegina176183CountryCitiesPopulation
FranceMarseille794811CountryCitiesPopulation
FranceParis2138551CountryCitiesPopulation
FranceBordeaux231844CountryCitiesPopulation
FranceLyon472317CountryCitiesPopulation
FranceNice338620CountryCitiesPopulation
FranceStrasbourg274845CountryCitiesPopulation
FranceToulouse433055CountryCitiesPopulation
FranceLille228328CountryCitiesPopulation
FranceNantes277269CountryCitiesPopulation
FranceDijon149782CountryCitiesPopulation
FranceAmiens143086CountryCitiesPopulation

 

The goal is to put the correct names of the axes and the legend without hardcoding it.

 

2022-07-07_09-52-55.png

 

I saw that you can't do this via DAX: 

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Change-column-header-names-dynamically-in-a-t...

Do you know if there is another way to do this please?

Thanks

 

1 ACCEPTED SOLUTION
esquiveljc
Frequent Visitor

The only way I've found is to eliminate the two axis names in Power BI and replace them with a visual card.

 

2022-07-07_14-07-15.png

View solution in original post

3 REPLIES 3
esquiveljc
Frequent Visitor

The only way I've found is to eliminate the two axis names in Power BI and replace them with a visual card.

 

2022-07-07_14-07-15.png

Surya9
Helper V
Helper V

@esquiveljc you can rename the column name 1,2& 3 as Country , Cities and Populations respectively in power query mode (Transform Data ) 

@Surya9Thanks for your quick response, but as written in my post I can't hardcode because the Country, Cities and Population column names may change in the datasource.

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.