Forum Discussion
MTD FOR PREVIOUS PERIOD
- 4 years ago
Hi @ganenthra94
Here is the formula modified for your case. You need also to use the month name in the visual instead of the year (from the pevious date table). However this won't work with my samp[el file as it's data has only monthly ganularity. So please try with your data.
MTD = VAR NumOfMonths = -2 VAR ReferenceDate = MAX ( 'Date'[Date] ) VAR PreviousDates = FILTER ( DATESINPERIOD ( 'PreviousDate'[Date], ReferenceDate, NumOfMonths, MONTH ), DAY ( 'PreviousDate'[Date] ) <= DAY ( ReferenceDate ) ) VAR Result = CALCULATE ( SUM ( 'Sales'[Salesl] ), REMOVEFILTERS ( 'Date' ), KEEPFILTERS ( PreviousDates ), USERELATIONSHIP ( 'PreviousDate'[Date], 'Date'[Date] ) ) RETURN Result
What do you mean change the period of PARALLELPERIOD to 1 month? Could not find it in the link you shared. Thanks once again.
Hi @ganenthra94
Here is the formula modified for your case. You need also to use the month name in the visual instead of the year (from the pevious date table). However this won't work with my samp[el file as it's data has only monthly ganularity. So please try with your data.
MTD =
VAR NumOfMonths = -2
VAR ReferenceDate =
MAX ( 'Date'[Date] )
VAR PreviousDates =
FILTER (
DATESINPERIOD ( 'PreviousDate'[Date], ReferenceDate, NumOfMonths, MONTH ),
DAY ( 'PreviousDate'[Date] ) <= DAY ( ReferenceDate )
)
VAR Result =
CALCULATE (
SUM ( 'Sales'[Salesl] ),
REMOVEFILTERS ( 'Date' ),
KEEPFILTERS ( PreviousDates ),
USERELATIONSHIP ( 'PreviousDate'[Date], 'Date'[Date] )
)
RETURN
Result- Anonymous4 years agoNot applicable
Will try but would this enable me to compare with any other month? tamerj1
- tamerj14 years ago
Community Champion
Anonymous
It will enable you to compare the selected month with the previous (N) months. So if you set the months -2 you will see 2 months (the selected month and the month before). If youe set the months -3 you will see 3 months (the selected month and the two before) and so on.- Anonymous4 years agoNot applicable
I shall try this but is there a way that I will be able to compate for example 1st to the 24th of May 2022 to any previous month, within the same period?
For example January or February 2022 1-24th, without explicitly changing the DAX? tamerj1
- Anonymous4 years agoNot applicable
Also what is the Previousdate? Is it a separate table that I need to create? tamerj1