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
ALRUYOYO
Advocate I
Advocate I

How to write quotation marks to get a single quotation mark when exported to csv?

Hey,
I am struggling to find a solution maybe someone can help.
Quotes PBI.JPG
In power BI I see the result I need where text is inside SINGLE quotation marks and separated by a comma, but when I export it to CSV I get multiple quotes around text.Quotes Notepad.JPG
Could someone suggest a solution? I would love to have this process ended at Power BI without any further excel or notepad edits. Thank you for your time.

Algirdas


5 REPLIES 5
ALRUYOYO
Advocate I
Advocate I

Thanks guys, as it is now, I export csv without quotes and add them using excel template. I think it's more simple than exporting to sql. All this process is done in order to create Bulk payment file for the bank. Even though it's super simple adding quotes in excel template, I would love for the process to end in PBI and leave no room for human error. I will check Code() function, but for one country I need CSV file with 52 columns, so I will need to write Code() 104 times? 🙂

Hi there,

 

Quotes can definitely be tricky! In Power Query and DAX the escape character for a quotation mark inside a string is represented as ""(two quotation marks).

 

For example, a string containing a single quotation mark would be written as:

 

""""

 

If you were to do a concatenated column as you described above it would look like something below:

 

Calc Column = """" & Table1[Column1] & """,""" & Table1[Column2] & """,""" & Table1[Column3] & """,""" & Table1[Column4] & """,""" & Table1[Column5] & """"

 

Which would produce this result: ("Combining","Data","Can","Be","Fun")

 

Quote.png


There's also a great question & post about this topic here. Let me know if this helps!

Hi @Reid_Havens,

 

I think @ALRUYOYO has that mastered.  The problem they are having is when using the Export to CSV feature on the visuals, they get all the extra """" characters.

 

I had a look to see if there were some Escape characters or an ASCII function he could use to minimise the noise, but there doesn't seem to be one.  We have a CODE() function that will provide the ASCII value of a character, but nothing the otherway that jumps out at me.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Ah good clarification, thanks Phil. The export to csv definitely adds an extra layer of logic that needs to be accounted for. It's a great question, I'll noodle on this a bit since now I'm curious if there's a way to do this without too much heavy lifting.

If the objective is to extract data out of Power BI, then here is one option

 

http://powerbi-pro.com/export-data-to-sql/

 

It uses an R Visual to export to an SQL DB, but you can probably modify it to write to a flat file as an option.  An R visual will export the data relevant to the currently selected filters too.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

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.