How to calculate Previous Month Sales

Note: the Total value for the Month 2024 - 09 = 60+70+80 is the Running total of from the Starting of the Month upto September, Similarly 2024-10 = 80+90+100 is the Running total of from the Starting of the Month upto October,

I want to calculate only October Sales = (80+90+100)-(60+70+80) = 60,

I calculated a Date Column: parseDate(concat(‘01’,‘-’,toString({Month}),‘-’,toString({Year})),‘dd-MM-yyyy’)
form this Date Column, I will calculate MonthName, Month-Year, Day-Month Number column.

I am using the below function to calculate it, i am getting errors, pls help me

  1. sum(Total Sales)
  2. lag(
    sum({Total Sales}),
    [{Date} ASC],
    1
    )

Hello @Venkat.Metadata

Using the share sample data, I could get the Current Month total sales - Previous Month total sales using the below calculations:

a) runningTotal-eachMonth

sumOver(sum({Total Sales}),[Month])

b) Sale-prevSale

lag({runningTotal-eachMonth},[Month ASC],1)

c) totalSaleMonth-totalSalePrevMonth

{runningTotal-eachMonth}-{Sale-prevSale}

Please note, in the visual I grouped the table by Month and Year, so that we get the total for each month

This is my final output:

1 Like

Hi @Venkat.Metadata,
It’s been awhile since we last heard from you on this thread, did you have any additional questions or were you able to find a work around for your case?

If we do not hear back within the next 3 business days, I’ll close out this topic.

Thank you!

Hi @Venkat.Metadata,
Since we have not heard back, I’ll go ahead and close out this topic. However, if you have any additional questions, feel free to create a new post in the community and link this discussion for relevant information in case needed.

Thank you!