Forum Discussion

nagasaikumarb22's avatar
3 years ago
Solved

get previous month data with filter

Hi all,

I was working on requirement that when we select september month in filter bar.I need to get data in table of date range of august month of a date column.The same should follow for all month selections.February date range  when clicked on march.

Thanks in advance.

 

4 Replies

  • nagasaikumarb22 , With help from a date table, Try a measure like

     

    MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
    last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
    last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
    MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
    last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
    last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))

     

    Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
    Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

     

    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

  • v-yadongf-msft's avatar
    v-yadongf-msft
    Icon for Community Support rankCommunity Support

    Hi nagasaikumarb22 ,

     

    This is my test table:

     

    Create a measure:

     

    Previous month value = CALCULATE(SUM('Table'[Value]), FILTER(ALL('Table'),'Table'[Month] = SELECTEDVALUE('Table'[Month]) -1))

     

     

    You will get previous month value:

     

    Best regards,

    Yadong Fang

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