Forum Discussion

GJUDGE's avatar
GJUDGE
Helper II
4 years ago
Solved

Comparing Periods in the same table

I am sure this is a fairly straightforward problem for most but I'm fairly new to Power BI and any help is appreciated!   I have a single table that compiles monthly reporting information. I want t...
  • v-xiaotang's avatar
    v-xiaotang
    4 years ago

    Hi GJUDGE 

    You can use Edate() function to get last period, for example, 

    Last Period = 
        var _currentDate=MAX('table'[date])
        var _lastDate=EDATE(_currentDate,-1)
    return 
        CALCULATE(SUM('table'[Output]),'table'[date]=_lastDate)

    Kindly note:  Edate() function has some limitations,

    If you can't use Edate() on some occasions, you can try this measure,

    Last Period = 
        var _maxDate=MAX('table'[date])
        var _lastDate=DATE(YEAR(_maxDate),MONTH(_maxDate)-1,1)
    return 
        CALCULATE(SUM('table'[Output]),'table'[date]=_lastDate)

     

     

    Best Regards,

    Community Support Team _Tang

    If this post helps, please consider Accept it as the solution to help the other members find it more quickly.