Skip to content

Commit 90f53bb

Browse files
committed
Split by sofa example
1 parent d15c614 commit 90f53bb

File tree

2 files changed

+28
-19
lines changed

2 files changed

+28
-19
lines changed
28.5 KB
Binary file not shown.
Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
let
22
/*
3-
the original question: <https://www.reddit.com/r/PowerBI/comments/1eay2qp/make_changescorrections_to_previously_made_column/>
4-
*/
5-
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bY5BCsIwEEWvMnQdd17AKrhRK0RwUboY6aQZTDOSJpvi4R0t3bn58If3H9O21UVS9mDFIWxhIsyUYAOJB5/hDWeJMxqwGHttd8+Z4MXDSDFTDw0HTcGnEhL4i9zsfld1ZvU6ET2eOJJa6lBI27Jq/q5+cUz4gKsUp4/YEUNQokaeycChTHn1LKPuAw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Full Name" = _t]),
6-
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Full Name", type text}}),
7-
#"Split Column by Delimiter - old" = Table.SplitColumn(#"Changed Type", "Full Name",
8-
Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), {"Full Name.1", "Full Name.2", "Full Name.3", "Full Name.4"}
9-
),
10-
#"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Full Name",
11-
Splitter.Sofa
12-
// Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), {"Full Name.1", "Full Name.2", "Full Name.3", "Full Name.4"}
13-
),
3+
the original question is from 2024-07-25: <https://www.reddit.com/r/PowerBI/comments/1eay2qp/make_changescorrections_to_previously_made_column/>
4+
5+
You can get the pbix and this query here: <https://github.com/ninmonkey/ninMonkQuery-examples/tree/main/forumQuestions>
146

7+
They are named:
8+
"2024-07 - Split By Sofa Name.pbix"
9+
"pq/2024-07 - Split By Sofa Name.pq"
10+
*/
11+
Json = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TY7LDoJADEV/pWGNK/0BwegKJRkTF4RFlQITZ6jOYyHh4y0mEDc3vcnpaasqObMLPShuEXbgCQM52IDTXR9ggoKHEVNQODTSbr0OBC/dWRoCNXDRRpLxKQQbPSNXle+TOq2SUjuE7WL0s38SSpvVVpBl94Ejo5WWs2mWOTP4eILEO5KTCz4QmX/5L04O71BybOVfZdHMRIZ6pBQO0QexRFqX6i8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Full Name" = _t]),
12+
Source = Table.TransformColumnTypes( Json ,{{"Full Name", type text}}),
1513
/*
1614
about: custom splitting by delimiter "|"
1715

@@ -34,17 +32,28 @@ let
3432
Size = crumb{0}?,
3533
#"Fabric Option" = crumb{1}?,
3634
#"Leg Option" =
37-
if shouldSwap then crumb{3}?
38-
else crumb{3}?,
35+
if shouldSwap
36+
then crumb{3}?
37+
else crumb{2}?,
3938

4039
#"Mattress Foam Option" =
41-
if shouldSwap then crumb{2}?
40+
if shouldSwap
41+
then crumb{2}?
4242
else crumb{3}?
4343
]
4444
][return],
45-
a = Table.SplitColumn ,
46-
b = Splitter.Sofa( #"Changed Type"{0}[Full Name] ),
47-
fin = #"Split Column by Delimiter"
48-
// #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Full Name.1", type text}, {"Full Name.2", type text}, {"Full Name.3", type text}, {"Full Name.4", type text}})
45+
46+
SplitByPipe = Table.AddColumn( Source, "SplitCols", each Splitter.Sofa( [Full Name] ), type record ),
47+
#"Expanded SplitCols" = Table.ExpandRecordColumn(
48+
SplitByPipe, "SplitCols",
49+
{ "Size", "Fabric Option", "Leg Option", "Mattress Foam Option"} ),
50+
51+
#"Changed Type" = Table.TransformColumnTypes(
52+
#"Expanded SplitCols", {
53+
{"Size", type text},
54+
{"Fabric Option", type text},
55+
{"Leg Option", type text},
56+
{"Mattress Foam Option", type text} } )
57+
4958
in
50-
fin
59+
#"Changed Type"

0 commit comments

Comments
 (0)