Created
August 26, 2023 15:34
-
-
Save cbaragao/38a4d8c3e59a8cc8e4e5113f43e32933 to your computer and use it in GitHub Desktop.
Excel BI PQ Challenge #107
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let | |
| Source = Excel.CurrentWorkbook(){[Name = "Table1"]}[Content], | |
| #"Added Coalesce" = Table.AddColumn(Source, "Coalesce", each [Column2] ?? [Column3] ?? [Column1]), | |
| #"Filtered Rows" = Table.SelectRows(#"Added Coalesce", each ([Coalesce] <> null)), | |
| #"Added Date" = Table.AddColumn( | |
| #"Filtered Rows", | |
| "Date", | |
| each try Date.From([Column1]) otherwise null, | |
| type date | |
| ), | |
| #"Added Index" = Table.AddIndexColumn(#"Added Date", "Index", 0, 1, Int64.Type), | |
| #"Inserted Integer-Division" = Table.AddColumn( | |
| #"Added Index", | |
| "Integer-Division", | |
| each Number.IntegerDivide([Index], 6), | |
| Int64.Type | |
| ), | |
| #"Removed Other Columns" = Table.SelectColumns( | |
| #"Inserted Integer-Division", | |
| {"Coalesce", "Date", "Integer-Division"} | |
| ), | |
| #"Grouped Rows" = Table.Group( | |
| #"Removed Other Columns", | |
| {"Integer-Division"}, | |
| { | |
| {"Dates", each List.Max([Date]), type date}, | |
| {"All", each _, type table [Coalesce = any, Date = date, #"Integer-Division" = number]} | |
| } | |
| ), | |
| #"Build Output List" = Table.AddColumn( | |
| #"Grouped Rows", | |
| "Output", | |
| each List.Combine( | |
| {List.Range([All][Coalesce], 2, 2), {[All][Coalesce]{4} + [All][Coalesce]{5}}} | |
| ) | |
| ), | |
| #"Removed Other Columns1" = Table.SelectColumns(#"Build Output List", {"Dates", "Output"}), | |
| #"Extracted Values" = Table.TransformColumns( | |
| #"Removed Other Columns1", | |
| {"Output", each Text.Combine(List.Transform(_, Text.From), ","), type text} | |
| ), | |
| #"Split Column by Delimiter" = Table.SplitColumn( | |
| #"Extracted Values", | |
| "Output", | |
| Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), | |
| {"PO Number", "Supplier", "PO Value"} | |
| ) | |
| in | |
| #"Split Column by Delimiter" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment