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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
eaj
Helper I
Helper I

Remove square Brackets from column headers DAX Query

I am currently streamlining a project in which we export data in CSV format to an external system. In the past, I have successfully created a table in Power BI with the same layout as I desire for my export. I would then go to optimize queries, press refresh, and copy the DAX query code from there.

 

However, in this instance, I am encountering an issue where square brackets are appearing around all of the column names. The column names consist of a single word in the format 'name_subname,' with no square brackets and despite my efforts, I cannot find a solution to remove these square brackets.

 

I am automating this process with Power Automate, and the flow works perfectly, except for the square brackets. Unfortunately, this issue is causing the external system to be unable to read my files.

 

Is there anyone who can provide assistance or guidance on resolving this issue?

 

Table PBI 

eaj_0-1706730980490.png

DAX Query:

DEFINE
    VAR __DS0Core = 
        SUMMARIZE(
            'Provetdata till SVA',
            [Consultation_ID],
            [Consultation_started],
            [Consultation_ended],
            [Clinic_ID],
            [Postal_code],
            [Postal_city],
            [Animal_ID],
            [Species_ID],
            [Species],
            [Breed_ID],
            [Breed],
            [Gender_ID],
            [Gender],
            [Deceased],
            [Date_of_birth],
            [Diagnosis_date],
            [Diagnosis_code],
            [Diagnosis]
        )

    VAR __DS0Filtered = 
        FILTER(
            __DS0Core,
            [Diagnosis_date] > TODAY() - 8 && 'Provetdata till SVA'[Diagnosis_date] < TODAY()
        )

    VAR __DS0PrimaryWindowed = 
        TOPN(
            100000,
            __DS0Filtered,
            [Consultation_ID], 1,
            [Consultation_started], 1,
            [Consultation_ended],1,
            [Clinic_ID],1,
            [Postal_code],1,
            [Postal_city],1,
            [Animal_ID],1,
            [Species_ID],1,
            [Species],1,
            [Breed_ID],1,
            [Breed],1,
            [Gender_ID],1,
            [Gender],1,
            [Deceased],1,
            [Date_of_birth],1,
            [Diagnosis_date],1,
            [Diagnosis_code],1,
            [Diagnosis],1
        )

EVALUATE
    SELECTCOLUMNS(
        __DS0PrimaryWindowed,
        "Consultation_ID", [Consultation_ID],
        "Consultation_started", [Consultation_started],
        "Consultation_ended", [Consultation_ended],
        "Clinic_ID", [Clinic_ID],
        "Postal_code", [Postal_code],
        "Postal_city", [Postal_city],
        "Animal_ID", [Animal_ID],
        "Species_ID", [Species_ID],
        "Species", [Species],
        "Breed_ID", [Breed_ID],
        "Breed", [Breed],
        "Gender_ID", [Gender_ID],
        "Gender", [Gender],
        "Deceased", [Deceased],
        "Date_of_birth", [Date_of_birth],
        "Diagnosis_date", [Diagnosis_date],
        "Diagnosis_code", [Diagnosis_code],
        "Diagnosis", [Diagnosis]
    )

ORDER BY
    [Consultation_ID],
    [Consultation_started],
    [Consultation_ended],
    [Clinic_ID],
    [Postal_code],
    [Postal_city],
    [Animal_ID],
    [Species_ID],
    [Species],
    [Breed_ID],
    [Breed],
    [Gender_ID],
    [Gender],
    [Deceased],
    [Date_of_birth],
    [Diagnosis_date],
    [Diagnosis_code],
    [Diagnosis]

 

Data output (File and in the new DAX query editor)

eaj_1-1706731024210.png

eaj_2-1706731138953.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

 Hi @eaj ,

Hmm. The square brackets are kinda needed as they separate the column name from the table name. However

You can try it:

$Results |export-csv -Path $ExportPath -NoTypeInformation
(Get-Content -Path $ExportPath ) -replace '[\[\]]' |Set-Content -Path $ExportPath

This allows you to not include square brackets in the production csv file

The following post will help you:

Solved: Removing square brackets from column headers DAX q... - Microsoft Fabric Community

Best Regards,

Xianda Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

 Hi @eaj ,

Hmm. The square brackets are kinda needed as they separate the column name from the table name. However

You can try it:

$Results |export-csv -Path $ExportPath -NoTypeInformation
(Get-Content -Path $ExportPath ) -replace '[\[\]]' |Set-Content -Path $ExportPath

This allows you to not include square brackets in the production csv file

The following post will help you:

Solved: Removing square brackets from column headers DAX q... - Microsoft Fabric Community

Best Regards,

Xianda Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.