Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
shiveshsingh
Master
Master

Getfieldselection

I want sum of salary for year one less than what i select.

suppose i select 2011, then i would require sum of salary in 2010

Below expression is not giving correct results.

=sum({<Date ={$(=(GetCurrentSelections(Date)-1))}>}salary)

8 Replies
Anil_Babu_Samineni

Try like

I assume, You have year values in date field

Sum({<Date = {'$(=Max(Date)-1)'}>} salary)

or

I assume, you have Year field where you already declare in script like Year(Date) as Date

Sum({<Year = {'$(=Max(Year)-1)'}>} salary)

or

Still you want to get last year date sales you can use like below

Sum({<Date = {'$(=AddYears(Max(Date),-1))'}>} salary)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
shiveshsingh
Master
Master
Author

No. not like that.

I have used this expression, i am building using getfieldselection, can you help?

Anil_Babu_Samineni

Without knowing anything, we can't offer much. But use GetFieldSelections() may be?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
sunny_talwar

Your Date field contains Year?

shiveshsingh
Master
Master
Author

yes, year

sunny_talwar

Then you best bet will be to use the expression provided by Anil.

Sum({<Year = {'$(=Max(Year)-1)'}>} salary)

Not sure why you want to complicate matters by using GetFieldSelections()? Is there a reason why you want to use this? Knowing the reason might help us give you a better response here

shiveshsingh
Master
Master
Author

hi

i have done this using this Sum({<Year = {'$(=Max(Year)-1)'}>} salary), just wanted to build it through Getfieldselection..


just a curiosity

sunny_talwar

If you will only select one year, then may be this

Sum({<Year = {'$(=GetFieldSelections(Year)-1)'}>} salary)