Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
3 years ago
Solved

Subtract current vs previous month

I have a data that has the date day / month / year, another column where the amount is on that date, and you are associated with different categories and products, what I need to do is a table of Category / sale of last month / sale of the current month, what formula can I occupy to calculate these two fields?, and that is connected with the whole sheet, For example I put in the filter month October I get the info of October in current month and last month I associate it with September?, because I achieve something but I always need to put only two months so that it can, because if I get to put more months I am adding the other months, attached image of my table

In the last month this September, and in the current October, but if I get to defilter the month of September, there is only ocubtre in the filter and nothing is seen in the table, attached as I calculate the vta month last and vta month current

Vtas Current Month = CALCULATE(sum('Sell in'[CLP]),PARALLELPERIOD('Sell in'[Calendar Day],1,MONTH))
Vtas Last Month = CALCULATE(sum('Sell in'[CLP]), PARALLELPERIOD('Sell in'[Día natural],-1,MONTH))
Any help will do!
Thanks a lot
  • Hi Syndicate_Admin ,

     

    Based on your description, I have created a simple sample:

    Please try:

    Vtas Last Month = CALCULATE(SUM('Table'[Amount]),FILTER(ALLEXCEPT('Table','Table'[Category]),[Date]>EOMONTH(MAX('Table'[Date]),-2)&&[Date]<=EOMONTH(MAX('Table'[Date]),-1)))
    
    Vtas Current Month = SUM('Table'[Amount])

    Final output:

     

    Best Regards,

    Jianbo Li

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

3 Replies

  • Hi Syndicate_Admin ,

     

    Based on your description, I have created a simple sample:

    Please try:

    Vtas Last Month = CALCULATE(SUM('Table'[Amount]),FILTER(ALLEXCEPT('Table','Table'[Category]),[Date]>EOMONTH(MAX('Table'[Date]),-2)&&[Date]<=EOMONTH(MAX('Table'[Date]),-1)))
    
    Vtas Current Month = SUM('Table'[Amount])

    Final output:

     

    Best Regards,

    Jianbo Li

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

    • Syndicate_Admin's avatar
      Syndicate_Admin
      Administrator

      Hello, I have a query

      I have the following columns ON HAND (Number), ON ORDER (Number), DATE (Number), SELL OUT (Number), Week (Number) what I need are the following conditions,

      It always has to be met for SELL OUT = 0,

      If On hand = 0 and On order is maintained with respect to the previous two weeks throw comment Transito Pastado.

      If On Hand is other than Zero and On Order is 0 you have to throw Ghost Stock comment.

      I'm doing a column with the following DAX code, space is where conditions are missing, any help with that codicion thank you very much!

      Status =
      SWITCH(TRUE(),
      'Export History'[ON HAND] <> 0 && 'Export History'[ON ORDER] = 0, "Phantom Stock",
      'Export History'[ON HAND] = 0 && , "Stuck Transit",
      BLANK()
      Best regards
      )