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: 
luigilettera
Contributor
Contributor

Calculation in the previous year with if statement with sum and aggr

Hello,

I have the following formula that works very well for the year that I select, but if I want to run the same calculating ​​for the previous year does not work by returning to zero.

Formula year selected (which is fine):

if (index (GetFieldSelections (status), 'EMPLOYEE')> 0 or GetSelectedCount (status) = 0, sum({<[anno]={$(=Max([anno]))},status={'DIPENDENTE'}>}aggr(sum({<[anno]={$(=Max([anno]))},status={'DIPENDENTE'}>}aggr(((percentuale/100) * ($ (VImpiegoRisorsaNONsomministrati))), year, month, RagSoc, centro_di_costo, Descr_deposito, name)), year, month, RagSoc, centro_di_costo, Descr_deposito, name)), 0)

The formula used for the calculation of the previous year is as follows:

if (index (GetFieldSelections (status), 'EMPLOYEE')> 0 or GetSelectedCount (status) = 0, sum ({<[year] = {$ (= Max ([year]) -1)}, {status = ' EMPLOYEE '}>} aggr (sum ({<[year] = {$ (= Max ([year]) -1)}, {status =' EMPLOYEE '}>} aggr (((percentage / 100) * ($ (vImpiegoRisorsaNONsomministrati))), year, month, RagSoc, centro_di_costo, Descr_deposito, name)), year, month, RagSoc, centro_di_costo, Descr_deposito, name)), 0)


0 Replies