Forum Discussion
Dynamic Before Previous Month and Further
Hi Everyone,
I have a Report Date column that looks like this:
| Jun-24 |
| Mar-24 |
| Dec-23 |
| Sep-23 |
| Jun-23 |
I have a measure that calculates this:
I can get the June 2024 result by using the $Sample measure itself and March 2024 results using PREVIOUSDAY but for December 2023 onwards, it does not provide the expected result.
When I am trying to incorporate the PrevReportDate Dax to my $Sample sum measure, it does not provide an accurate result but rather, giving us the current month's result. Can anyone recommend a workaround?
I was using this DAX to try to get the December 2023 results but it is showing June 2024's data:
Thanks!
Deligraphs Use PARALLELPERIOD to go back specific numbers of months, quarters, or years:
When calculating values for previous periods, apply the PARALLELPERIOD or DATEADD functions directly in your calculation measure:
aPrevNSOPrevHeadroomOutstanding_92 =
VAR PrevPeriod = CALCULATE(MAX('04DateTable'[Date]), PARALLELPERIOD('04DateTable'[Date], -3, MONTH))
VAR Calc = SUM(Sample) * 1000000
VAR Results = CALCULATE(Calc, '04DateTable'[Date] = PrevPeriod)
RETURN ResultsAdjust PARALLELPERIOD to MONTH, QUARTER, or YEAR as needed, based on your report’s date structure. This method should yield correct results for each report date, regardless of the period gaps.
Deligraphs Hope it works.
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
1 Reply
- fahadqadir3
Solution Supplier
Deligraphs Use PARALLELPERIOD to go back specific numbers of months, quarters, or years:
When calculating values for previous periods, apply the PARALLELPERIOD or DATEADD functions directly in your calculation measure:
aPrevNSOPrevHeadroomOutstanding_92 =
VAR PrevPeriod = CALCULATE(MAX('04DateTable'[Date]), PARALLELPERIOD('04DateTable'[Date], -3, MONTH))
VAR Calc = SUM(Sample) * 1000000
VAR Results = CALCULATE(Calc, '04DateTable'[Date] = PrevPeriod)
RETURN ResultsAdjust PARALLELPERIOD to MONTH, QUARTER, or YEAR as needed, based on your report’s date structure. This method should yield correct results for each report date, regardless of the period gaps.
Deligraphs Hope it works.
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!