Forum Discussion
Generate new rows based on Quarter Year table in Power Query
- 2 years ago
Hi WM117 ,
How about this:
I first created a lookup table called TableQM specifying the months per quarter:
Here the code in Power Query M that you can paste into the advanced editor (if you do not know, how to exactly do this, please check out this quick walkthrough)
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TcqxDQAgCEXBXaw1UfgMYk3Yfw2J1euuuMxxz7JtPmq2DXZY8P/CF77whR/4gR/47Xo=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [QuarterYear = _t]), #"Added Custom" = Table.AddColumn(Source, "Custom", each [QuarterYear]), #"Split Column by Delimiter" = Table.SplitColumn(#"Added Custom", "Custom", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"Custom.1", "Custom.2"}), #"Merged Queries" = Table.NestedJoin(#"Split Column by Delimiter", {"Custom.1"}, TableQM, {"Quarter"}, "TableQM", JoinKind.LeftOuter), #"Expanded TableQM" = Table.ExpandTableColumn(#"Merged Queries", "TableQM", {"Month"}, {"TableQM.Month"}), #"Added Custom1" = Table.AddColumn(#"Expanded TableQM", "Custom", each [TableQM.Month] & "/" & Text.End([Custom.2], 2)), #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Custom.1", "Custom.2", "TableQM.Month"}) in #"Removed Columns"Let me know if this solves the issue 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
Hi WM117 ,
How about this:
I first created a lookup table called TableQM specifying the months per quarter:
Here the code in Power Query M that you can paste into the advanced editor (if you do not know, how to exactly do this, please check out this quick walkthrough)
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TcqxDQAgCEXBXaw1UfgMYk3Yfw2J1euuuMxxz7JtPmq2DXZY8P/CF77whR/4gR/47Xo=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [QuarterYear = _t]),
#"Added Custom" = Table.AddColumn(Source, "Custom", each [QuarterYear]),
#"Split Column by Delimiter" = Table.SplitColumn(#"Added Custom", "Custom", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"Custom.1", "Custom.2"}),
#"Merged Queries" = Table.NestedJoin(#"Split Column by Delimiter", {"Custom.1"}, TableQM, {"Quarter"}, "TableQM", JoinKind.LeftOuter),
#"Expanded TableQM" = Table.ExpandTableColumn(#"Merged Queries", "TableQM", {"Month"}, {"TableQM.Month"}),
#"Added Custom1" = Table.AddColumn(#"Expanded TableQM", "Custom", each [TableQM.Month] & "/" & Text.End([Custom.2], 2)),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Custom.1", "Custom.2", "TableQM.Month"})
in
#"Removed Columns"
Let me know if this solves the issue 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
- WM1172 years agoFrequent Visitor
Thanks for helping, this worked!