Forum Discussion

sousahebert's avatar
sousahebert
Frequent Visitor
8 years ago

Get data from same weekday from last month

Hi,

 

I'd like to know how to get values from same period in last month. 

For exampe:

 

Data                Value

02/01/2018 (2th Month Weekday) -  100

04/12/2018 (2th Month Weekday) -  110

03/01/2018 (3th Month Weekday)  -200

05/12/2018 (3th Month Weekday)  -240

I need the data like this

 

Data                    M0              Previous Month

02/01/2018    100                 110

03/01/2018   200                  240

 

Is it possible?

 

Tks

 

 

10 Replies

  • sousahebert's avatar
    sousahebert
    Frequent Visitor

    Hi,

     


    I'd like to know how to get values from same period in last month.

    For exampe:

     

    Data Value

    02/01/2018 (2th Month Workday) - 100

    04/12/2018 (2th Month Workday) - 110

    03/01/2018 (3th Month Workday) -200

    05/12/2018 (3th Month Workday) -240

    I need the data like this

     

    Data M0 Previous Month

    02/01/2018 100 110

    03/01/2018 200 240

     

    Is it possible?

     

    Tks

     

     

    • ccakjcrx's avatar
      ccakjcrx
      Icon for Resolver I rankResolver I

      Hey sousahebert!

       

      I may not be understanding you correctly, but here is what I came up with based on how I understood your problem. 

       

       

      Here is the measure: 

       

      MsrValueLastMonth = 
      CALCULATE(SUM(Sheet1[Value]),
      PREVIOUSMONTH(Sheet1[Date])
      )

      Hope that helps. If not, leave a comment indicating that is the case.

      • sousahebert's avatar
        sousahebert
        Frequent Visitor

        i'v already tryied it.. but don't worked.....

         

        using previousmont or dateadd(date,-1,month) , the result is:

         

        Date             M0     M-1

         

        04/12/2017  110   

        05/12/2017  240    

        02/01/2018 100     5000

        03/01/2018  200    5000

         

        its return the full last month value (5000 its the value between 01/12/2017 and 31/12/2017)....

  • sousahebert

     

    You accidentally posted the same thing twice. Can you delete this post? I posted what will hopefully be helpful in the other post; if it is not helpful, just leave a comment in the other post.

  • Hey sousahebert!

     

    Sorry I'm just now getting back to this. It looks like you might be after the value from thirty days ago. Here is the formula I used:

     

    MsrValueLastMonth = 
    SUMX(
        DATEADD(MES_ATUAL[Data de Cadastramento 2],-30,DAY),
        [Qtd_Processo_M0]
    )

    Assuming that is what you need, this expression should help. It simply goes back thirty days and executes the [Qtd_Processo_M0] measure. You can change the second parameter of the DATEADD expression to go back a certain number of days. You don't have date values for every day of the month in the MES_ATUAL table, so some rows will be blank. Here is what it looks like in the table visual:

     

     

    HERE is a link to your sample file with the added expression.

     

    Hope this helps.