You can try the following, the steps are
- Create a list of the Present Months
- Calculate the maximum month
- Get the distinct categories
- Generate a list of all future months contain in 2021, and calculate with
ADDCOLUMNS
the start of the months.
- Take only the future months using
EXCEPT
- Cross Join the future months with the distinct categories, that would give you all the combinations possible.
ADDCOLUMNS
to the CROSSJOIN
table, where [value]
is calculated using the [variable]
name and the max month from the table you provided. VAR
is used to access the row context, so we can use FILTER
.
Calculated Table
Future =
VAR PresentMonths =
ALL ( 'Table'[Date] )
VAR maxMonth =
MAXX ( 'Table', [Date] )
VAR DistinctCat =
ALL ( 'Table'[variable] )
VAR AllMonths =
SUMMARIZE (
ADDCOLUMNS (
CALENDAR ( DATE ( 2021, 01, 01 ), DATE ( 2021, 12, 31 ) ),
"MonthStart", DATE ( YEAR ( [Date] ), MONTH ( [Date] ), 01 )
),
[MonthStart]
)
VAR FutureMonths =
EXCEPT ( AllMonths, PresentMonths )
VAR FutureTable =
ADDCOLUMNS (
CROSSJOIN ( FutureMonths, DistinctCat ),
"value",
CALCULATE (
SUM ( 'Table'[value] ),
VAR localVariable = [variable]
RETURN
FILTER ( 'Table', [variable] = localVariable && [Date] = maxMonth )
)
)
RETURN
UNION ( 'Table', FutureTable )
Output
Date |
variable |
value |
---|
December 2020 |
PLOB |
50000 |
December 2020 |
PC |
20000 |
January 2021 |
PC |
30000 |
January 2021 |
PLOB |
40000 |
February 2021 |
PC |
50000 |
February 2021 |
PLOB |
60000 |
March 2021 |
PC |
20000 |
March 2021 |
PLOB |
50000 |
April 2021 |
PC |
60000 |
April 2021 |
PLOB |
70000 |
May 2021 |
PC |
60000 |
May 2021 |
PLOB |
70000 |
June 2021 |
PLOB |
70000 |
June 2021 |
PC |
60000 |
July 2021 |
PC |
60000 |
July 2021 |
PLOB |
70000 |
August 2021 |
PC |
60000 |
August 2021 |
PLOB |
70000 |
September 2021 |
PC |
60000 |
September 2021 |
PLOB |
70000 |
October 2021 |
PC |
60000 |
October 2021 |
PLOB |
70000 |
November 2021 |
PC |
60000 |
November 2021 |
PLOB |
70000 |
December 2021 |
PC |
60000 |
December 2021 |
PLOB |
70000 |