Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreShape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.
I have data as shown in the first column "CurrentInput" what I want to do is split it, but I need to flip around the order first as shown in "Flipped".
I can't find a good way to do this.
I tried doing a Text.Reverse, splitting, then Text.Reverse each column that comes back, and that seems to be an option.
However, it seems like there should be a more elegant way to accomplish this?
Can I do all of it in a single step, Text.Reverse, feed that to the splitter, then Reverse each output column back again???
My final output goal is to have the columns which I would name Region, Store, Category, Date.
CurrentInput | Flipped | Region | Store | Category | Date |
2022-01,Sales,Store925,Region1 | Region1,Store925,Sales,2022-01 | Region1 | Store925 | Sales | 2022-01 |
2022-02,Sales,Store854,Region2 | Region2,Store854,Sales,2022-02 | Region2 | Store854 | Sales | 2022-02 |
2022-05,Sales,Store235,Region2 | Region2,Store235,Sales,2022-05 | Region2 | Store235 | Sales | 2022-05 |
2022-01,Sales,Store001,Region3 | Region3,Store001,Sales,2022-01 | Region3 | Store001 | Sales | 2022-01 |
My Advanced Editor text
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtI1MNQJTsxJLdYJLskvSrU0MtUJSk3PzM8zVIrVgSkxQlZiYWoCVWKEpMQUWYmRsSkWJSgWGQC5ECXGSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CurrentInput = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"CurrentInput", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.Reverse([CurrentInput])),
#"Split Column by Delimiter" = Table.SplitColumn(#"Added Custom", "Custom", Splitter.SplitTextByDelimiter(",", QuoteStyle.None), {"Custom.1", "Custom.2", "Custom.3", "Custom.4"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Custom.1", type text}, {"Custom.2", type text}, {"Custom.3", type text}, {"Custom.4", type text}})
in
#"Changed Type1"
Solved! Go to Solution.
Hello, @OneWithQuestion
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtI1MNQJTsxJLdYJLskvSrU0MtUJSk3PzM8zVIrVgSkxQlZiYWoCVWKEpMQUWYmRsSkWJSgWGQC5ECXGSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CurrentInput = _t]),
column_names = { "Date", "Category", "Store", "Region" },
output_goal =
Table.ReorderColumns(
Table.FromRows(
List.Transform(
Source[CurrentInput],
Splitter.SplitTextByDelimiter(",")
),
column_names
),
List.Reverse(column_names)
)
in
output_goal
no. It won't work. To retain all other columns lets transform column items to list >> list reverse >> list to record with known names and finally expand this column of records.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtI1MNQJTsxJLdYJLskvSrU0MtUJSk3PzM8zVNJRSgTiVKVYHZhSI2SlFqYmUKVGQGVJQJyGpNQUWamRsSmS0mQgTkdSiuIAAyAXotQYqCwFiDOUYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CurrentInput = _t, other_column01 = _t, other_column02 = _t]),
column_names = { "Region", "Store", "Category", "Date" },
output_goal =
Table.ExpandRecordColumn(
Table.TransformColumns(
Source,
{
{"CurrentInput",
(x) =>
Record.FromList(
List.Reverse(
Splitter.SplitTextByDelimiter(",")(x)
),
column_names
)
}
}
),
"CurrentInput",
column_names
)
in
output_goal
Hello, @OneWithQuestion
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtI1MNQJTsxJLdYJLskvSrU0MtUJSk3PzM8zVIrVgSkxQlZiYWoCVWKEpMQUWYmRsSkWJSgWGQC5ECXGSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CurrentInput = _t]),
column_names = { "Date", "Category", "Store", "Region" },
output_goal =
Table.ReorderColumns(
Table.FromRows(
List.Transform(
Source[CurrentInput],
Splitter.SplitTextByDelimiter(",")
),
column_names
),
List.Reverse(column_names)
)
in
output_goal
Thank you so much!
I'm trying to properly understand this and adapt it.
I'm running into an issue with retaining existing columns in the table.
If in the example I provided, I wanted to only split the first column (which you did) but KEEP those other columns in the table, how does the syntax work for that?
How can you use Table.ReorderColumns to only address specific columns instead of the entire table?
no. It won't work. To retain all other columns lets transform column items to list >> list reverse >> list to record with known names and finally expand this column of records.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtI1MNQJTsxJLdYJLskvSrU0MtUJSk3PzM8zVNJRSgTiVKVYHZhSI2SlFqYmUKVGQGVJQJyGpNQUWamRsSmS0mQgTkdSiuIAAyAXotQYqCwFiDOUYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CurrentInput = _t, other_column01 = _t, other_column02 = _t]),
column_names = { "Region", "Store", "Category", "Date" },
output_goal =
Table.ExpandRecordColumn(
Table.TransformColumns(
Source,
{
{"CurrentInput",
(x) =>
Record.FromList(
List.Reverse(
Splitter.SplitTextByDelimiter(",")(x)
),
column_names
)
}
}
),
"CurrentInput",
column_names
)
in
output_goal
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Check out the November 2024 Power BI update to learn about new features.
User | Count |
---|---|
24 | |
13 | |
12 | |
11 | |
8 |
User | Count |
---|---|
43 | |
26 | |
16 | |
15 | |
12 |