Forum Discussion
Mike22
8 years agoHelper III
Split 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
Anonymous
8 years agoNot applicable
HI Mike22,
Can you please share your pbix file with sample source data to test?
Regards,
Xiaoxin Sheng
Mike22
8 years agoHelper III
Anonymous
I was about to write to you, I just found the issue. The excel source file had 2 completely blank rows that could not be seen as null when filtering on the row but were impacting the calculation.
Thanks a lot for another great solution.
Mike