Forum Discussion

Deligraphs's avatar
Deligraphs
Regular Visitor
2 years ago
Solved

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:   $Sample = SUM(Sample)...
  • fahadqadir3's avatar
    2 years ago

    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 Results

    Adjust 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!!