Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
g_f_bakker
Partner - Contributor
Partner - Contributor

Variable in Aggr formula

Hello community members,

I have a problem with a variable in my aggregation formula:

=Sum(If(Aggr(NODISTINCT Max(DEVEMPDATEKEY,240),SUBDEVICE_ID='2')<=DEVEMPDATEKEY,1,0) * AMOUNT)

I want a substitute for the part SUBDEVICE_ID='2' into a variable:  {<SUBDEVICE_ID={"$(vDevIdStation1)"}>}

Please help me with the syntax.

Many thanks, Gerard.

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Try

=Sum(If(Aggr(NODISTINCT Max({<STATION={"$(='0'&vStation1)"}>}DEPSTATDATENR,60),STATION)<=DEPSTATDATENR,1,0) * QTYPC)

Because your variable doesn't contain the value 02, but 2 it's necessary to add the 0 in the set modifier.


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
MK_QSL
MVP
MVP

Can you please elaborate your expression ?

g_f_bakker
Partner - Contributor
Partner - Contributor
Author

Hi Manish,

See attached file. The station is now a fixed number in the aggr function and I like to work with a variable.

The expression is about the last 60 and 240 records of a aggregated sorting per station.

Many thanks for your answer.

Gerard.

Gysbert_Wassenaar

Try

=Sum(If(Aggr(NODISTINCT Max({<STATION={"$(='0'&vStation1)"}>}DEPSTATDATENR,60),STATION)<=DEPSTATDATENR,1,0) * QTYPC)

Because your variable doesn't contain the value 02, but 2 it's necessary to add the 0 in the set modifier.


talk is cheap, supply exceeds demand
g_f_bakker
Partner - Contributor
Partner - Contributor
Author

Hi Gysbert,

That’s brilliant!!

The 2 and 02 was my error, the former result set was without the 0.

It’s working perfectly now!

Many thanks, Gerard. (oftewel: SUPER bedankt man!!)