Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sum previous quantity vs selected date

Hi to all I'm a new QV user and I have a problem to sum some values...
Here my problem, I need to sum values where the data is smaller the the select data:
For example:
I have 4 column
Data
Month
Category
Quantity
If I select month = november I want to sum all the previus quantity... and If  I filter category= Cat1, I want to sum all the previous (before novembre) quantity but only from Cat1
Es.
Jan to october Cat1 --> Sum(Quantity) = 10
Jan to october Cat2 -->sum(Quantity) = 2
If I select november I want as result 12 If I select november cat 1 I want 10
I tried with this but it doesn't work
=
sum({<Data = {"<=$(<Data)"}>} Quantita)
Can somebody help me
Thx
Sabina
P:S:Attached the file
4 Replies
SunilChauhan
Champion
Champion

use below code

sum({$<Mese = {"<=$(=Mese)"}>} Quantita)

hope this helps

Sunil Chauhan
Not applicable
Author

unfortunately it doesn't work,  the problem is that I need to sum all the values where the date is smaller then the selected date.  if I use = is not correct, would be < but I think that can't use logic operator in this kind of string.....

If I insert the code in my test file (attached) the result is 30 instead 26 futhermore if I select some days it dosen't work

...any other idea ?

thx in advance

Sabina

Not applicable
Author

You'll need to convert the Date into Date in your script and then use it in the set analysis. As far as using Months is concerned: you can try: Sum({$<Mese = {'<=$(=max(Mese))'}>}Quantita)

Not applicable
Author

I have already found a part of the solution...I mean If I use this

Sum({$<[Data] = {"<=$(=Date(num(min(Data))-1))"}>} Quantita)

when I select some values in the Data field, it's work corectly...

but If I select month or year the previus code doesn't work... the problem is that I don't know which fields the user want to use...

Thx again

Sabina