Forum Discussion

ALRUYOYO's avatar
ALRUYOYO
Advocate I
9 years ago

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.

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.
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

  • Reid_Havens's avatar
    Reid_Havens
    Most Valuable Professional

    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")

     


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

    • Phil_Seamark's avatar
      Phil_Seamark
      Microsoft Employee

      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.

      • Reid_Havens's avatar
        Reid_Havens
        Most Valuable Professional

        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.

  • 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? :)