Skip to content

Commit d15c614

Browse files
committed
first pass
1 parent 36aa9dd commit d15c614

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
let
2+
/*
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+
),
14+
15+
/*
16+
about: custom splitting by delimiter "|"
17+
18+
- always ignore the trailing "TSCO"
19+
- 3 or less columns expand as:
20+
a, b, c
21+
- 4 columns expand swapped as:
22+
a, b, d, c
23+
24+
- where a, b, c, d are:
25+
- Size
26+
- Fabric Option
27+
- Mattress Foam Option
28+
- Leg Option
29+
*/
30+
Splitter.Sofa = (source as text) => [
31+
crumb = List.RemoveLastN( Text.Split( source, "|" ), 1 ),
32+
shouldSwap = List.Count( crumb ) = 4,
33+
return = [
34+
Size = crumb{0}?,
35+
#"Fabric Option" = crumb{1}?,
36+
#"Leg Option" =
37+
if shouldSwap then crumb{3}?
38+
else crumb{3}?,
39+
40+
#"Mattress Foam Option" =
41+
if shouldSwap then crumb{2}?
42+
else crumb{3}?
43+
]
44+
][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}})
49+
in
50+
fin

0 commit comments

Comments
 (0)