# QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
cancel
Showing results for
Did you mean:
Creator

## Set analysis for scrollin previuos year and three month

Hello guys,

I need to extract the bought quantity for the last year in the current month and in the further two (now it should be may/jun/jul 2021)

I've set the formula for the previous year, but I need some help with the second condition:

=Num(Aggr(Sum({<AnnoCompetenza={"\$(=Year(Today())-1)"}>} QtaAcquistata), CodArticolo),'#.##0')

Could someone help me, pls?

Thanks.

N.

Labels (1)
• ### Application Development

2 Solutions

Accepted Solutions
Creator
Author

Got it!

=Sum({<AnnoCompetenzaACQ={"\$(=Year(Today())-1)"}, MeseCompetenzaACQ={">=\$(=Num(Month(Today())))<=\$(=Num(Month(Today()))+2)"}>} QtaAcquistataStorica)

Thank you for the support :-).

N.

Master

it appears your month is not a date but a number.  that would have been a great info to have.    i would suggest you use a real date as your solution is not scalable.  if this were a real date you wouldnt need to test for year.

14 Replies
Master

use addmonths and addyears,  you can use actual date instead of testing the year, or if you have the month

or if you are using start of the month as your month field:

Master
Creator
Author

Thank you for the explanation, Edwin...sorry, but I wasn't clear enough in my question: I already have the availability of the reference year (AnnoCompetenza) and the reference Month (MeseCompetenza), but I'm not able to get the correct syntax for the set analysis to sum the Qty (QtaAcquistata) for the current month and the further two in the previous year (in this moment may/jun/jul 2021, but it has to roll, of course) for each article.

Hope now it's much clear now.

Thanks.

N.

Master

assuming your month field MeseCompetenza is start of the month, like 1/1/2022,

Master

thats what i meant by using start and end dates in your set analysis

Creator
Author

Thank you, Edwin...sorry but your syntax seems to be incorrect (and I'm not able to understand where is the error).

P.S.: Your assumption that MeseCompetenza starts from the first month day and ends at the last one is correct.

For example:

Year      Month  Quantita

2021       5              210

2021       6              220

2021       7              230

2021       8              240

In this case, until May, 31st 2022 I have to show 210+220+230=360; from June 1st 2022 I have to show 220+230+240=390

Hope it's clear.

Thanks.

N.

Master

i would think that there is something else going on, Qlik is saying it doesnt recognize the fieldnames, eithere there is some other text outside the window or the field names are not correctly (case wise).  copy paste the bottom of the editor where Qlik interprets the expression.  pay attention to the format of the evaluated \$()

Master

i was missing a comma.  also you dont need the first monthstart:

Master

this is obviously Qlik Sense but the same is seen in QlikView: