Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
FisherShi
Contributor II
Contributor II

how to calculate the spend of last month

Hi everyone,

my data has 3 fields:

    [Load Month] contains 1/1/2021, 2/1/2021,3/1/2021, 4/1/2021, 5/1/2021 with  date format like "MM/DD/YYYY"

    [Total Cost Gross] spend of each item

    [Item] 

 

i want to compare the spend of this month vs. last month. i can use Sum({1<[Load Month] = {'$(=Date(max([Load Month])))'}>} [Total Cost Gross]) to get the spend of this month, how can i calculate the spend of last month?

i tried to make the expression like below, however it doesn't work. Can anyone please help? thanks you very much.

Sum({1<[Load Month] = {'$(=Date(max([Load Month])-32))'}>} [Total Cost Gross])

Regards,

Fisher

Labels (3)
1 Solution

Accepted Solutions
MayilVahanan

HI @FisherShi 

Try like below

Sum({1<[Load Month] = {"$(=Date(AddMonths(max([Load Month]),-1),'MM/DD/YYYY'))"}>} [Total Cost Gross])

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

2 Replies
MayilVahanan

HI @FisherShi 

Try like below

Sum({1<[Load Month] = {"$(=Date(AddMonths(max([Load Month]),-1),'MM/DD/YYYY'))"}>} [Total Cost Gross])

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
FisherShi
Contributor II
Contributor II
Author

Thanks Mayil. it works😁

have a nice day.

Regards,

Fisher