Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
bhaveshp90
Creator III
Creator III

Expression for getting December month value for previous Year?

Hello,

I have a table as shown below.

1.PNG

My expression for selecting December month data of previous year for all the months for As Sold Upd OEC (Baseline) is not working.

=Aggr(NODISTINCT Sum({<Year = {$(vPreYear)} , Month = {$(vPreYearLastMonth)},  [Cost_Area] = {'Mechanical Engineering (labor + travel)'}, Snapshot_Date = >}Updated_OEC_Budget) , [Cost_Area])

What wrong am I doing here?

stalwar1‌ Can you help me on this?

Any help is appreciated? thanks

12 Replies
bhaveshp90
Creator III
Creator III
Author

I have declared the variables in the back script as

vPreYear =Year(YearEnd(AddYears(max(Snapshot_Date),-1)))

vPreYearLastMonth =Month(YearEnd(AddYears(max(Snapshot_Date),-1)))

Is this something wrong in setting the variables

1.PNG

sunny_talwar

Try this

Let vPreYear = '=Year(YearEnd(AddYears(max(Snapshot_Date),-1)))';

Let vPreYearLastMonth = '=Num(Month(YearEnd(AddYears(max(Snapshot_Date),-1))))';

and use this expression

Sum(TOTAL <Cost_Area> {<Year = {'$(vPreYear)'} , Num_Month = {'$(vPreYearLastMonth)'}, Cost_Code = {'3'}, Snapshot_Date = >}Updated_OEC_Budget)

bhaveshp90
Creator III
Creator III
Author

Awesome it worked. Thank you Sunny . I understood what should I do now