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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Kevin8
Frequent Visitor

Renaming column headers when importing data from a semantic model to Excel

I'm trying to import a table from a semantic model into Excel. I can get the data, but I need the same column headers that are present in the Power Bi Report, and the data via Queries and Connections shows the raw column headers with no obvious option to edit them.

I found a way to edit the headers in the Dax code;

-> Queries and Connections

-> Properties

-> Defintion

-> Command text:


I rename the columns, by editing the SELECTCOLUMNS statement. Following is an example:

 

DEFINE
VAR __DS0Core = 
SELECTCOLUMNS(
KEEPFILTERS(
FILTER(
KEEPFILTERS(
SUMMARIZECOLUMNS(
'TABLE'[COLUMN],
"CountRowsSCE", COUNTROWS('TABLE')
)
),
NOT(ISBLANK('TABLE'[COLUMN]))
)
),
"NEW COLUMN NAME", 'TABLE'[COLUMN]
)
VAR __DS0BodyLimited = 
TOPN(
1000000,
__DS0Core,
"NEW COLUMN NAME",
1)
EVALUATE
__DS0BodyLimited
ORDER BY
"NEW COLUMN NAME"

 

However, the issue is, when the table is viewed in Excel the column header is always wrapped in [ ]  eg:  [NEW COLUMN NAME]

 

This excel spreadsheet is to be used by power automate for looking up data, and the column headers won't be recognised with the extra [  ].

Does anyone have a code solution to this?

A secondary issue is that the column order is changed whenever you edit a column, it disapears and appears at the end of the table, this seems to overide the column order listed in the query.   Not sure why this is, seems to be a bug. 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User
2 REPLIES 2
Kevin8
Frequent Visitor

Thanks for this suggestion. It does do the trick. It never occured to me to start a second query so I could bring all the tools of power query into play.

lbendlin
Super User
Super User

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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