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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
micheledio
Contributor
Contributor

Info su somma mesi

Buonasera,

Vorrei sapere come fare ad eseguire una somma solo degli ultimi 4 mesi relativi ad una quantità già presente in ognuno dei 12 mesi, esempio:

Media pezzi venduti per articolo negli ultimi 4 mesi, in Excel vado a selezionare direttamente le colonne interessate degli ultimi quattro mesi, ma in QLIK non riesco a farlo.

Vi ringrazio anticipatamente

Michele

Labels (1)
3 Replies
Digvijay_Singh

Best and fast solution is to create an indicator in the script like this - 

if(monthend([Trans Date]) >= monthend(addmonths(Today(1),-4)) and monthend([Trans Date]) < monthend(Today(1)), 1,0) as Last_4months_ind

and then in the expression use it like this - 

Sum({<Last_4months_ind = {1}>}Quantity)

You might need to adjust the expression based on your needs as such whether you need running month included or not.

If you need to select last 4 months based on your selection made in the period related field, then you need to move your script solution to 'Sum' expression but that needs to be coded differently.

Thanks,

micheledio
Contributor
Contributor
Author

Ok, grazie per la risposta, volvevo sapere se al posto di "Trans Date" e "Today" devo scrivere qualcosa di diverso?

Digvijay_Singh

Trans Date should be replaced with your data model date field that is used for the period calculation. Today(1) is the current date. The expression I shared, goes back 4 months from the End of the day of last month. it doesn't include the running month days.