Forum Discussion
Power BI - Use List to Generate Column Headers when Splitting Column by Delimiter
- Anonymous3 years ago
Hi amitchandak ,
I figured out how to do this.
Rather than having the List.Transform function select the number of columns, I added referenced my list here, then amended the "each" clause to it pulled the name from the list. As below:
= Table.SplitColumn(#"Added Data Source", "Taxonomy_Campaign", Splitter.SplitTextByDelimiter(#"DV360 Campaign Name - Delimiter", QuoteStyle.Csv), List.Transform(#"DV360 Campaign Name - Fields", each Text.From(_)))Thanks,
Mark
Anonymous ,
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Check if these can help
Calculation Groups- Measure Slicer, Measure Header Grouping, Measure to dimension conversion. Complex Table display : https://youtu.be/qMNv67P8Go0
Show dynamic column name
https://perytus.com/2021/02/04/improve-ux-show-year-in-legend-when-using-time-intelligence-measures/
dynamic Column Header
https://www.youtube.com/watch?v=yEemVBiaTuk
https://www.goodly.co.in/dynamic-column-names-power-query/
https://www.thebiccountant.com/2018/07/04/efficiently-rename-column-names-with-a-function-in-power-bi-and-power-query/
https://community.powerbi.com/t5/Desktop/Dynamic-column-name-from-its-value/td-p/189442
Hi amitchandak ,
I posted a whole response to this, but for some reason it's totally disappeared. However ... I've made some progress with a potential solution. But I still need some help.
I've done a standard splittextbydelimiter to see the coding. When I do this, I see the following:
Table.SplitColumn(#"Taxonomy Match - Line Item", "Campaign_Name", Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), {"Campaign_Name.1", "Campaign_Name.2", "Campaign_Name.3", "Campaign_Name.4", "Campaign_Name.5", "Campaign_Name.6", "Campaign_Name.7"})
So I wondered if I could perhaps convert my list into a string, to then pass through where different Column Names appear. So I tried the following:
= Table.SplitColumn(#"Taxonomy Match - Line Item", "Campaign_Name", Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), {Text.Combine(#"DV360 Campaign Name - Fields",",")})
With this I'm trying to create the string. In my list table, I added "" to the start and end of each row. However when I go this, it renames the first column with this string, as below:
Do you know how I can convert this string to replace the code so it uses each field from the list as a Header for each column?
Thanks,
Mark