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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
master_student
Creator III
Creator III

AGGR Expression issue

Hello everyone,

I am using an expression with AGGR function :

Sum (Aggr(  Sum({< $(vSetView)>} POKTND) , LB,Famille,CODE_PROJET,PO_FOURNISSEUR,PO_NUM_COMMANDE,PO_COMMENTS, PO_ACHETEUR,[Month of date], CDR) )

but the problem is that I am using $(vSetView) to show MTD /YTD / Total YEAR data , so that the data change with the selection :

Capture.PNG

$(vSetView)=pick(ViewId,

'$(vSetMTD)',

'$(vSetYTD)',

'$(vSetTotal)')

View:

LOAD * INLINE [

    ViewId, View

    1, MTD

    2, YTD

    3, Total Year

];

any help so that my data change with the selection please?

Thanks

Labels (1)
10 Replies
master_student
Creator III
Creator III
Author

Any idea please...

inescastelhano
Partner - Creator II
Partner - Creator II

Hi,


You are not evaluating your expression... Look at your variable:

Sum (Aggr(  Sum({< $(vSetView)>}


You are supposed to have something like Date = $(myvariable) ....


Cheers,

Ines

master_student
Creator III
Creator III
Author

Thanks Ines, could explain more please

Anonymous
Not applicable

Hi,

Try replacing $(vSetView) with $(=$(vSetView))

--

Maurice

master_student
Creator III
Creator III
Author

No it didn't work Maurice

Sum (Aggr(  Sum($(=$(vSetView)) POKTND) , LB,Famille,CODE_PROJET,PO_FOURNISSEUR,PO_NUM_COMMANDE,PO_COMMENTS, PO_ACHETEUR, CDR) )

Anonymous
Not applicable

You need to adapt your script like my below example that works very well:

View:

LOAD * INLINE [

    ViewId, View

    1, 2008

    2, 2009

];

SET vSet2008='Year={2008}';

SET vSet2009='Year={2009}';

SET vSetView=pick(ViewId, vSet2008, vSet2009);

Then use expression like: sum({< $(=$(vSetView)) >} Sales)

master_student
Creator III
Creator III
Author

sum({< $(=$(vSetView)) >} Sales) works very well but whene I use AGGR FUNCTION it doesn't work; the amount doesn't change with the selection.


Sum (Aggr(  Sum($(=$(vSetView)) POKTND) , LB,Famille,CODE_PROJET,PO_FOURNISSEUR,PO_NUM_COMMANDE,PO_COMMENTS, PO_ACHETEUR, CDR) )

Anonymous
Not applicable

Hi Bekir,

In my example if i use same template as you:

=sum(aggr(sum({< $(=$(vSetView)) >} Sales), CategoryName))

It also works well...

So i think you have something wrong maybe with the fields you are using.

Be sure also to put = sign to start the expression as sum is a function.

--

Maurice

master_student
Creator III
Creator III
Author

As recommended, see below

=sum(aggr(sum({< $(=$(vSetView)) >} POKTND), LB,Famille,CODE_PROJET,PO_FOURNISSEUR,PO_NUM_COMMANDE,PO_COMMENTS, PO_ACHETEUR, CDR) )

Bellow are my variable expressions :

'$(vSetMTD)', : [Calendar date]=  ,   [Month of date]={ "= $(=max([Month of date]))"},  [%Date ID] = { "<= $(=max([%Date ID]))"}

'$(vSetYTD)', :  [Year of date]={ $(=[Year of date]) } , [Month of date]={ "<= $(=max([Month of date]))"} , [%Date ID] = { "<= $(=max([%Date ID]))"}

'$(vSetTotal)') : [Calendar date]=, [Month of date]=,  [Year of date]={ $(=[Year of date]) }

$(vSetView)=pick(ViewId,

'$(vSetMTD)',

'$(vSetYTD)',

'$(vSetTotal)')

The amount remains the same with all selections MTD/YTD and total year...

did I miss something?

Thanks