Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
Not applicable

aggr function for current selection

We have following Expression

= Sum(

          Aggr(

                  Count(DISTINCT

                  IF(C_Stagione = '$(sSaison1)',

                  if (DT_Ordine >= if (isnull(dVon1) or dVon1 = '', DT_Ordine, dVon1) AND

                                    DT_Ordine <= if (isnull(dBis1) or dBis1 = '', DT_Ordine, dBis1), C_Cliente),

                  IF(C_Stagione = '$(sSaison2)',

                  if( DT_Ordine >= if (isnull(dVon2) or dVon2 = '', DT_Ordine, dVon2)  AND

                                    DT_Ordine <= if (isnull(dBis2) or dBis2 = '', DT_Ordine, dBis2), C_Cliente)))), C_Cliente  ) )

sSaison1, sSaison2, dVon1, dVon2, dBis1, dBis2 are in an INPUTBOX

The (total) result is only correct for current selections.

For example in any case we need to have current selection for C_Stagione (which is the same as sSaison..)

The results work fine with following Expression

count (distinct {$<C_Stagione = {$(#sSaison1),$(#sSaison2)}>}  C_Cliente)

but this expression does not consider further conditions (dVon.., dBis..)

Any idea how to solve ?

1 Solution

Accepted Solutions

Re: aggr function for current selection

Try this expression:

=Count({

  <C_Stagione = {'$(sSaison1)'}, DT_Ordine = {"$(='>=' & TimeStamp(dVon1) & '<=' & TimeStamp(dBis1))"}> +

  <C_Stagione = {'$(sSaison2)'}, DT_Ordine = {"$(='>=' & TimeStamp(dVon2) & '<=' & TimeStamp(dBis2))"}>

  } distinct C_Cliente)

33 Replies
Not applicable

Re: aggr function for current selection

Re: aggr function for current selection

I might be able to offer better help if you are able to share a sample qvf file?

Not applicable

Re: aggr function for current selection

see example

Re: aggr function for current selection

You will have to provide me with some other information as which chart are we looking at? What is the expected output based on the qvw provided?

Not applicable

Re: aggr function for current selection

Look at chart "Data contro data" (the second one)

Expression : Nr.clienti YTD (starting with SUM-AGGR and IFs) : only total is correct

CORRECT DATA : correct data (but this expression is without IFs)

C_Stagioni are current selection

Re: aggr function for current selection

I am still trying to understand this... will respond back when I have something for you.

Best,

Sunny

Not applicable

Re: aggr function for current selection

guess it has something to do with the AGGR function vs. Current Selections

Re: aggr function for current selection

Can you elaborate on the use of the other if statements here? You expect the same numbers as CORRECT DATA even though there are extra if statements?


if (DT_Ordine >= if (isnull(dVon1) or dVon1 = '', DT_Ordine, dVon1) AND

                                    DT_Ordine <= if (isnull(dBis1) or dBis1 = '', DT_Ordine, dBis1),

I guess I am wondering what exactly are you looking to do here?

Not applicable

Re: aggr function for current selection

In my example - in order to check results - I am assuming dVon and dBis in a way that this result is same as CORRECT DATA

Once Expression works I will restrict these Variables to get other results

Paolo Prinoth

Il giorno 06 mar 2017, alle ore 12:58, Sunny Talwar <qcwebmaster@qlikview.com<mailto:qcwebmaster@qlikview.com>> ha scritto: