Forum Discussion
gunman
3 years agoNew Member
Efficient way to create lookup table from multi-value column
Hi, I am playing with some IMDB files that can be downloaded from https://datasets.imdbws.com. One of the files (title.basics.tsv.gz) is a GZip file and contains basic information about each movie...
Nathaniel_C
Community Champion
3 years agoIt seems this way you can use your original table without creating a new one. I just did not include the movie title.
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos πare nice too.
Nathaniel
gunman
3 years agoNew Member
I am not sure what your proposed solution is, but your "
Source = Table.FromRows...is equivalent to my
(FileUrl) =>
let
Source = Web.Contents(FileUrl),
Decompress = Binary.Decompress(Source, Compression.GZip)
in
Decompressand both have to appear in two different queries in order to produce two different tables (Movies and MovieGenres). So, I don't see how this solves the problem.
BTW, you don't have to unpivot etc. If you split the multi-valued column to rows directly, the code is simplified (and is more flexible, since your code assumes there are only 2 different values):
The code in that case becomes:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUUrMy8xNLMnMz9NRKM7ILypRitWJVjICSpSnFpekFgGFi/JzE/OSU8ESxkCJ5Pzc1JRKHYXcSpCCSqXYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}, {"Column2", type text}}),
#"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Changed Type", {{"Column2", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Column2"),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column2", type text}})
in
#"Changed Type1"