Forum Discussion
Trying to add rows for missing months for each group
- 3 years ago
Hi , Anonymous
According to your description, you want to combine two tables group by [org_id] and generate the date from 'Organization'[contract_start] to the Max of 'Date'[Strat of Month]. Right?
You can realize it in Power Query Editor.
Here are the steps you can follow:
(1) This is my test data:
(2)We can add a new Blank Query and we put this in "Advanced Editor" :
let Source = Organization, Custom1 = Table.AddColumn(Source,"Date",(x)=> List.Select(Date[Start of Month],(y)=> y>=x[contract_start] ) ), #"Removed Columns" = Table.RemoveColumns(Custom1,{"contract_start"}), #"Expanded test" = Table.ExpandListColumn(#"Removed Columns", "Date") in #"Expanded test"(3)Then we can meet your need , the result is as follows:
For dax , you can create a table and enter this:
Table = var _t=CROSSJOIN('Organization','Date') var _t2=FILTER(_t,[Start of Month]>=[contract_start]) return SELECTCOLUMNS(_t2,"org_id",[org_id] , "Date" , [Start of Month])Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi , Anonymous
According to your description, you want to combine two tables group by [org_id] and generate the date from 'Organization'[contract_start] to the Max of 'Date'[Strat of Month]. Right?
You can realize it in Power Query Editor.
Here are the steps you can follow:
(1) This is my test data:
(2)We can add a new Blank Query and we put this in "Advanced Editor" :
let
Source = Organization,
Custom1 = Table.AddColumn(Source,"Date",(x)=> List.Select(Date[Start of Month],(y)=> y>=x[contract_start] ) ),
#"Removed Columns" = Table.RemoveColumns(Custom1,{"contract_start"}),
#"Expanded test" = Table.ExpandListColumn(#"Removed Columns", "Date")
in
#"Expanded test"
(3)Then we can meet your need , the result is as follows:
For dax , you can create a table and enter this:
Table =
var _t=CROSSJOIN('Organization','Date')
var _t2=FILTER(_t,[Start of Month]>=[contract_start])
return
SELECTCOLUMNS(_t2,"org_id",[org_id] , "Date" , [Start of Month])
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Thank you! That's exactly what I needed. Thank you also for the detailed explanation - my goal is to understand this stuff so I don't need to ask so many questions - you really helped me with that, too!