Forum Discussion

reendzz98's avatar
reendzz98
Helper I
3 years ago

Display previous month

Hi there. I need help to display previous month based on the data that I have. Below is the months that I have:

I get to display current month using measure max(Month). I tried to find measures through website but the one that I could find either to display sales on the current month or to display previous month based on real-time date. 

I want a measure that allows the powerBi to display 'August' and automatically displays 'September' when 'October' data comes in.

 

2 Replies

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Community Support

    Hi, reendzz98 ;

    First you can create a date column for the month, if you have one, you don't need to create another one, if not, create a new date column for the month: similar to the following:

    Then could try to create a measure to calculate the previous month's value:

    Previous = CALCULATE(SUM('Table'[value]),PREVIOUSMONTH('Table'[Date]),ALL('Table'))

    Or 

    Previous2 = CALCULATE(SUM('Table'[value]),DATEADD('Table'[Date],-1,MONTH),ALL('Table'))

    Or 

    Previous3 = CALCULATE(SUM('Table'[value]),FILTER(ALLSELECTED('Table'),EOMONTH([Date],0)=EOMONTH(MAX('Table'[Date]),-1)))

    The final show:


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Hi v-yalanwu-msft , thank you for your respond. I understand from your solution that it will display the value based on previous month, which is very helpful. I actually want to display the previous month only for example, the one that I have now allows to display the current month based on that I have in my table which is September.

    I want to be able to display the previous month which will allow it to display 'August' in the scorecard. Is that possible?