Forum Discussion

hchava5292's avatar
hchava5292
Frequent Visitor
3 months ago
Solved

Based on Dynamic period selection previous period value is incorrect

Hi All, I have a requirement of period selection last month, last 3 months, current month, next month, next 3 months, custom period where user will select there own start and end dates. My model is ...
  • andrewsommer's avatar
    3 months ago

    The bug is in these two lines:

    VAR _previousStartDate = EOMONTH(_currentStartDate, -2) + 1
    VAR _previousEndDate   = EOMONTH(_currentStartDate, -1)


    You're going back two months from the current start instead of one, so everything is off by a month. For Current Month, _currentStartDate is June 1; your formula lands on April instead of May.


    Replace those two lines with:

    VAR _previousEnd   = EOMONTH(_currentStart, -1)
    VAR _previousStart = EOMONTH(_previousEnd, -1) + 1