Forum Discussion
Mike22
Helper III
8 years agoSplit columns by Delimiter and create multiple rows in DAX
Hello, I have another challange for which I need your assistance. I have the following table Trip Number Full Itinerary 3564 (01)GENEVA,GE,SWITZERLAND to SKOPJE,FYRO MACEDONIA > , (02)S...
- Anonymous8 years ago
HI Mike22,
I don't think they can achieve through dax formula, you can take a look at following query query formula about transform format:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jY/LCsIwEEV/ZciqhVnEPhSXQzqtUZOWJFRq7dK1G/1/CxbxUcTdwNxzH30v0nyZCRSRXMQVW24JK0Z/0OHIbk+2gOsF/K5utoxl52owpLiorSY43aRMz4AQySSel4zsvOnEigF7kSfrqUBDlgyB0qHD6R4dyPjAriCDlsPmYeDf0+clI9uQ0x5XOZaOrOJXKo0/n/9kZb+yvto/Zw53", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Trip Number" = _t, #"Full Itinerary" = _t]), #"Added Custom" = Table.AddColumn(Source, "Itinerary", each List.RemoveLastN(List.Transform(Text.Split([Full Itinerary],">"),each Text.Trim(Text.End(_,Text.Length(_)-Text.PositionOf(_,")")-1)," ")),1)), #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Full Itinerary"}), #"Expanded Itinerary" = Table.ExpandListColumn(#"Removed Columns", "Itinerary"), #"Split Column by Delimiter" = Table.SplitColumn(#"Expanded Itinerary", "Itinerary", Splitter.SplitTextByDelimiter("to", QuoteStyle.Csv), {"Origin", "Destination"}), #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Trip Number", Int64.Type}, {"Origin", type text}, {"Destination", type text}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"Trip Number"}, {{"Contents", each Table.AddIndexColumn(_, "Index", 1, 1), type table}}), #"Expanded Contents" = Table.ExpandTableColumn(#"Grouped Rows", "Contents", {"Origin", "Destination", "Index"}, {"Origin", "Destination", "Index"}) in #"Expanded Contents"Regards,
Xiaoxin Sheng
Mike22
Helper III
8 years agoThanks Anonymous
for your usual very detailed reply.
Unfortunately I am getting the error below
Expression.Error: We cannot convert the value null to type Text.
Details:
Value=
Type=TypeWhen on the step
= Table.Group(#"Changed Type", {"Trip Number"}, {{"Contents", each Table.AddIndexColumn(_, "Index", 1, 1), type table}}),I checked and there are no null values in the trip number do you have any idea of what it could be?
Thanks a lot.
Mike
Anonymous
8 years agoNot applicable
HI Mike22,
Can you please share your pbix file with sample source data to test?
Regards,
Xiaoxin Sheng