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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

How to convert Values (Some Column Name) to CSV in DAX?

Hi All,

 

I have the data in columns,

 

VALUES (Some Column) and I wanted to somehow with DAX, convert column rows into a CSV - Row1, Row 2, Row 3, etc.

 

Thanks in advance.

1 ACCEPTED SOLUTION

Hi @Anonymous ,

Here are two output for your scenario.

Firstly, if you want to get the output below, you could use dax expression.

dax output.PNG

You could create the measure with the formula below.

Measure = CONCATENATEX('Table1','Table1'[Column],",")

If you want to get the Apple, Banana, Grape as a column name, you could achieve in Query Editor.

1. Transpose the Table.

2. Merge the columns.

3. Use first Row as header

Untitled.png

Hope this can help!

Best  Regards,

Cherry

 

Community Support Team _ Cherry Gao
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

6 REPLIES 6
Ayayo
New Member

This is the CSV file that I need to convert into DAX DATATABLE:

id,name,age,gender
1,Roberta,39,M
2,Oliver,25,M
3,Shayna,18,F
4,Fechin,18,M

 And this is the processed result:

DATATABLE (
    "id", STRING,
    "name", STRING,
    "age", STRING,
    "gender", STRING,
    {
        { "1", "Roberta", "39", "M" },
        { "2", "Oliver", "25", "M" },
        { "3", "Shayna", "18", "F" },
        { "4", "Fechin", "18", "M" }
    }
)

 

So, how does it quickly realize this requirement? An online tool is used here: https://tableconvert.com/csv-to-dax

it can also convert HTML Table, JSON, Markdown Table or Excel to DAX.

 

Note that your data is safe as all its conversion processing is done in your browser.

v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

I'm afraid that we cannot change the column name in the original table with dax.

If it is convenient, could you share some data sample and your desired output so that I could understand your scenario better and try other ways.

Best  Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi there,

 

Thanks for your message.

 

I am looking to convert some values returned in a column to comma separated values.

 

For e.g.

Input-

ALLSELECTED ('Products'[Product Name])

 

Apple

Banana

Grape

 

SOMEHOW WRITE A DAX TO MAGICALLY OUTPUT - CSV LIST

 

Apple, Banana, Grape

 

I hope this helps. Looking forward to any solution. Thanks.

 

Hi @Anonymous ,

Here are two output for your scenario.

Firstly, if you want to get the output below, you could use dax expression.

dax output.PNG

You could create the measure with the formula below.

Measure = CONCATENATEX('Table1','Table1'[Column],",")

If you want to get the Apple, Banana, Grape as a column name, you could achieve in Query Editor.

1. Transpose the Table.

2. Merge the columns.

3. Use first Row as header

Untitled.png

Hope this can help!

Best  Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi there!

 

I have a similar scenario to convert list to csv grouped by ID column, please help!

 

Input:

ID   Name

1       A

1       B

1       C

2       D

3       E

3       F

 

Output:

ID   Name

1      A,B,C

2      D

3      E,F

Anonymous
Not applicable

THANK YOU VERY MUCH!!

 

I cant believe it was that simple. 😉

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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