Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
rkpatelqlikview
Creator III
Creator III

Current Year Month and Last Year month set analysis

Dear Team,

I trying to get Last Year month sales after selecting Current Year months.

If select  currenct MonthYear Jun-2019,Jul-2019,Aug-2019 then i  need sales for previous Year same months Jun-2018,Jul-2018,Aug-2018 sales.

I tried with below expressions but not working. Please help on this.

Sum({<Year=,MonthYear=,
KeyDate={">$(=YearStart(Max(KeyDate),-1))=$(=AddYears(Max(KeyDate),-1))"}>} Sales)

Sum({$<Year=,KeyDate={">=$(=YearStart(Max(KeyDate),0))<=$(=AddYears(Max(KeyDate),0))"}>} Sales)

Sum({<YearMonth ={">=$(=Date(addmonths(Max(YearMonth), -12), 'MMM-YY'))<=$(=Date(addmonths(Max(YearMonth), -1), 'MMM-YY'))"}>}
Sales)

Labels (3)
1 Solution

Accepted Solutions
sunny_talwar

May be this

Sum({<MonthYear = {">=$(=Date(AddYears(Min(KeyDate), -1), 'MMM-YYYY'))<=$(=Date(AddYears(Max(KeyDate), -1), 'MMM-YYYY'))"}, Year, KeyDate>} Sales)

 

View solution in original post

5 Replies
sunny_talwar

Do you have YearMonth and MonthYear fields? Which field are you making a selection in? YearMonth or MonthYear? Also, do you need to go back to YearStart or just the same months for last year?

rkpatelqlikview
Creator III
Creator III
Author

Hi sunny,

Yes, I do have MonthYear Jan-2019 ....like this.

I am making selection in MonthYear only. 

I need to go for just last year same month.

rkpatelqlikview
Creator III
Creator III
Author

If i selected Jan-2019, Feb-2019,Mar-2019 then i need to see last Year sales for Jan,Feb,Mar 2018.

sunny_talwar

May be this

Sum({<MonthYear = {">=$(=Date(AddYears(Min(KeyDate), -1), 'MMM-YYYY'))<=$(=Date(AddYears(Max(KeyDate), -1), 'MMM-YYYY'))"}, Year, KeyDate>} Sales)

 

rkpatelqlikview
Creator III
Creator III
Author

Yes Sunny. Thanks a lot. Working perfect