March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
From an original XML-file I am trying to expand this column:
When I do this, I get the following result:
Some records are not at the 'text'-level, some are still tables. If I mark one of the records with table value, I can see the following content:
If I now try to expand the column, I get the following error:
How do I expand the column?
Solved! Go to Solution.
This seems to be a bit tricky. You add a column that checks if the content of the current row of the column to expand is of type table. In that case you take the value as it is and if not, you transform the text-value to table. That way all fields will be in table format and can be expanded:
let Source = {1, #table({"a", "A"}, {{"b", "B"}})}, #"In Tabelle konvertiert" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error), Step2 = Table.AddColumn(#"In Tabelle konvertiert", "Custom", each if Value.Is([Column1], type table) then [Column1] else #table({"ConvertedText"}, {{[Column1]}})), #"Erweiterte Custom" = Table.ExpandTableColumn(Step2, "Custom", Table.ColumnNames(Table.Combine(Step2[Custom])), Table.ColumnNames(Table.Combine(Step2[Custom]))) in #"Erweiterte Custom"
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi ImkeF.
I have inserted your code into a new query. Do I just need to change the source to my source?
I'm unsure as to amend your code so that it works on my source data.
Sorry for the dumb questions, I am new to Power BI!
Regards
Mike
Hi ImkeF,
I have managed to get this to work using your code.
Thank you so much for your help! 🙂
Regards
Mike
Hi ImkeF,
This line of code is returning a'null' when the value in Column1 is type table.
Step2 = Table.AddColumn(#"In Tabelle konvertiert", "Custom", each if Value.Is([Column1], type table) then [Column1] else #table({"ConvertedText"}, {{[Column1]}})),
Any idea why?
Thanks
Mike
Does is directly return a null or after you've expanded the column that this steps creates?
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi Imke F,
It was after the expansion of the columns. I have figured it out now. It was due to the column heading being a new heading, and the expansion wanted to expand two columns, but it only expanded one.
Thanks
Mike
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
128 | |
90 | |
75 | |
56 | |
53 |
User | Count |
---|---|
200 | |
104 | |
101 | |
67 | |
55 |