Forum Discussion
Month on Month Comparison based on another value
- Anonymous5 years ago
I think your Month column is text type, you may need to build a Month table as below.
Unrelated Month Table:
Then add a YearMonth column in your sample table.
YearMonth = VAR _MonthName = LEFT ( 'Table'[Month], 3 ) VAR _MonthNum = CALCULATE ( SUM ( 'Month'[MonthNumber] ), FILTER ( 'Month', 'Month'[Month] = _MonthName ) ) VAR _YearNum = FORMAT ( RIGHT ( 'Table'[Month], 2 ), "General Number" ) + 2000 RETURN _YearNum * 100 + _MonthNumBuild the billing in previous month column by YearMonth column.
Billing in Previous Month = VAR _PreviousMonth = MAXX ( FILTER ( 'Table', 'Table'[SageRef] = EARLIER ( 'Table'[SageRef] ) && 'Table'[YearMonth] < EARLIER ( 'Table'[YearMonth] ) ), 'Table'[YearMonth] ) RETURN CALCULATE ( SUM ( 'Table'[Billing] ), FILTER ( 'Table', 'Table'[SageRef] = EARLIER ( 'Table'[SageRef] ) && 'Table'[YearMonth] = _PreviousMonth ) )Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I think your Month column is text type, you may need to build a Month table as below.
Unrelated Month Table:
Then add a YearMonth column in your sample table.
YearMonth =
VAR _MonthName =
LEFT ( 'Table'[Month], 3 )
VAR _MonthNum =
CALCULATE (
SUM ( 'Month'[MonthNumber] ),
FILTER ( 'Month', 'Month'[Month] = _MonthName )
)
VAR _YearNum =
FORMAT ( RIGHT ( 'Table'[Month], 2 ), "General Number" ) + 2000
RETURN
_YearNum * 100 + _MonthNum
Build the billing in previous month column by YearMonth column.
Billing in Previous Month =
VAR _PreviousMonth =
MAXX (
FILTER (
'Table',
'Table'[SageRef] = EARLIER ( 'Table'[SageRef] )
&& 'Table'[YearMonth] < EARLIER ( 'Table'[YearMonth] )
),
'Table'[YearMonth]
)
RETURN
CALCULATE (
SUM ( 'Table'[Billing] ),
FILTER (
'Table',
'Table'[SageRef] = EARLIER ( 'Table'[SageRef] )
&& 'Table'[YearMonth] = _PreviousMonth
)
)
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Perfect, thanks very much