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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.