The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I have a data set comming from SQL, that is being passed through PowerBi Desktop.
I want to export certain data into CSV to afterwards import it back with excel.
But the issue is that in the data there are several fields which also have comma in it. And I don't want to erase all the comas of all the dataset for the export to work!
IS there any option to export with a different delimiter (for example a semicolon ";" or #, or use a text qualifier?
¿Or it's only possible to export with commas?
It would be great to add the possibility to export with a delimiter choosen by the user, or to at least add a text qualifier!
Solved! Go to Solution.
I'm responding myself.
After checking the datasource exported to .csv from PBI, I noticed that the .CSV file indeed had a text qualifier when comma's where inside the string.
So what was happening, is that in some part of the data, there was some strings that had 2 quotation marks inside.
For example there was a string that had <My name is "Jon Doe", and my mother name is "Jane Doe". What will be my pet's name?>
In that case there was a coma and 4 apostrophes, so of course there was chaos in my exported .csv ...
So what I did is that i erased all the apostrophes of the datasource. I had to make a special view in the SQL for PBI export,
using the formula REPLACE of SQL as this.
REPLACE(dbo.DB.Column_2, '"', '')
Above formula allows me to replace all apostrophes with nothing. Result is that all quotation marks had been erased (they weren't very important) an now the export from PBI .csv works like a charm.
I think this is possible to do all of this in PowerQuery, but I preffered to do it on the source.
Conclusion:
1)PBI Desktop exports .CSV with comma's as a delimiter, and use a quotation mark "XXXXX" as text qualifier when comma's are inside the string.
2)Is not possible to change the type of delimiter, or to change the text qualifier.
3) If your data has quotation marks " " inside the strings, they only solution is to erase it from the source or to be replaced with another character.
4) What I did was to do a special view only for PBI, that erased all "quotation marks" on the SQL source, and now export with .csv works like a charm.
5) It would be great to have a possibility to export directly to excel, or at least change the delimiters or the text qualifiers. Quotations marks are used too much to be the only possibility,
EDIT: I also had to delete char (10) linefeed and Char (13) carriage return for this trick to work.
SQL COLUMN = REPLACE(REPLACE(REPLACE(data, CHAR(13), ' '), CHAR(10), ' '), '"', '')
With that I erase quotation marks, linefeeds and carriage returns from the data.
HS.
I'm responding myself.
After checking the datasource exported to .csv from PBI, I noticed that the .CSV file indeed had a text qualifier when comma's where inside the string.
So what was happening, is that in some part of the data, there was some strings that had 2 quotation marks inside.
For example there was a string that had <My name is "Jon Doe", and my mother name is "Jane Doe". What will be my pet's name?>
In that case there was a coma and 4 apostrophes, so of course there was chaos in my exported .csv ...
So what I did is that i erased all the apostrophes of the datasource. I had to make a special view in the SQL for PBI export,
using the formula REPLACE of SQL as this.
REPLACE(dbo.DB.Column_2, '"', '')
Above formula allows me to replace all apostrophes with nothing. Result is that all quotation marks had been erased (they weren't very important) an now the export from PBI .csv works like a charm.
I think this is possible to do all of this in PowerQuery, but I preffered to do it on the source.
Conclusion:
1)PBI Desktop exports .CSV with comma's as a delimiter, and use a quotation mark "XXXXX" as text qualifier when comma's are inside the string.
2)Is not possible to change the type of delimiter, or to change the text qualifier.
3) If your data has quotation marks " " inside the strings, they only solution is to erase it from the source or to be replaced with another character.
4) What I did was to do a special view only for PBI, that erased all "quotation marks" on the SQL source, and now export with .csv works like a charm.
5) It would be great to have a possibility to export directly to excel, or at least change the delimiters or the text qualifiers. Quotations marks are used too much to be the only possibility,
EDIT: I also had to delete char (10) linefeed and Char (13) carriage return for this trick to work.
SQL COLUMN = REPLACE(REPLACE(REPLACE(data, CHAR(13), ' '), CHAR(10), ' '), '"', '')
With that I erase quotation marks, linefeeds and carriage returns from the data.
HS.