Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Dear all,
here my question. I have this sample table:
I need to create a custom function to split the columns by the /, and then unpivot them to get this:
As the original table is made up with roughly 2.000 rows, I have the feeling that using the lists is improving the efficiency of the query.
Could you help?
Thanks.
Solved! Go to Solution.
Hi @Mic1979
let
Source = Your_Source,
Text_Split = Table.TransformColumns(Source,
{{"Stuffing_Box_Material", each Text.Split(_, " / "), type text},
{"Body_Material", each Text.Split(_, " / "), type text}
}),
Expand1 = Table.ExpandListColumn(Text_Split, "Body_Material"),
Expand2 = Table.ExpandListColumn(Expand1, "Stuffing_Box_Material")
in
Expand2
Stéphane
Hi @Mic1979 ,
Thanks for reaching out to the Microsoft fabric community forum.
To identify the most efficient method, I replicated your scenario and tested both splitting by delimiter and by using Lists. I found that both methods loaded in a similar timeframe; however, it's important to note that my dataset contained approximately 1,000 rows. I wouldn’t say there is a significant advantage to using lists in this case. The advantage of using "Split by Delimiter" is that it is much simpler unless additional complex transformations are required after splitting the rows. In such scenarios, using lists may be the better option.
If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS.
Thanks and Regards
Hello
thanks for your feedback. Would it be possible for you to share a code with the lists I can use?
Thanks.
I thought you made a code with the list.
My bad.
Thanks.
Just split each of the columns into Rows, using one of the Advanced Options in the Split Column by Delimiter dialog
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCi4JLlEwNjTzUdBXQLC1FUKKUhNLclPzSoBs55zUxLzMvHQlHXTlITDlcCWxOtFKTkX5eVWpQNVORYnFxWAhuD5kM1BlFLQJ2olsTywA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Body Material" = _t, #"Stuffing Box Material" = _t]),
#"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(Source, {
{"Body Material", Splitter.SplitTextByDelimiter(" / ", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Body Material"),
#"Split Column by Delimiter1" = Table.ExpandListColumn(Table.TransformColumns(#"Split Column by Delimiter", {
{"Stuffing Box Material", Splitter.SplitTextByDelimiter(" / ", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Stuffing Box Material"),
#"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Stuffing Box Material", type text}})
in
#"Changed Type"
Thanks. Is it not quicker in terms of query efficiency to use the lists? I have big data to manage..
Thanks again, really appreciated.
Hi @Mic1979
let
Source = Your_Source,
Text_Split = Table.TransformColumns(Source,
{{"Stuffing_Box_Material", each Text.Split(_, " / "), type text},
{"Body_Material", each Text.Split(_, " / "), type text}
}),
Expand1 = Table.ExpandListColumn(Text_Split, "Body_Material"),
Expand2 = Table.ExpandListColumn(Expand1, "Stuffing_Box_Material")
in
Expand2
Stéphane
Hello slorin,
thanks for your code, I will accept it as a solution. If I wanted to make it more general, just to check to split those columns where the " / " is present, how to do this?
Thanks again
User | Count |
---|---|
30 | |
25 | |
24 | |
13 | |
9 |
User | Count |
---|---|
24 | |
19 | |
16 | |
13 | |
9 |