Forum Discussion

msommerf's avatar
msommerf
Icon for Helper III rankHelper III
5 years ago
Solved

DAX to find Previous Period

l would appreciate it if somebody could help with the following problem.   I have a date table that includes a custom period for a group of selected dates.  I can easily calculate the current peri...
  • amitchandak's avatar
    5 years ago

    msommerf , Make sure you have a separate period table(Say Date), Then create a rank column on period

     

    Period Rank = RANKX(all('Period'),'Period'[year period],,ASC,Dense) //YY-MM format column  in your case

     

    Then create measure like

    example 


    This Period = CALCULATE(sum('order'[Qty]), FILTER(ALL('Period'),'Period'[Period Rank]=max('Period'[Period Rank])))
    Last Period = CALCULATE(sum('order'[Qty]), FILTER(ALL('Period'),'Period'[Period Rank]=max('Period'[Period Rank])-1))

     

    Last year Period = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year])-1 && 'Date'[Period] = Max('Date'[Period])))

     

    Power BI — Month on Month with or Without Time Intelligence
    https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
    https://www.youtube.com/watch?v=6LUBbvcxtKA