Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
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
sunny_talwar

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)

View solution in original post

33 Replies
Not applicable
Author

sunny_talwar

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

Not applicable
Author

see example

sunny_talwar

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
Author

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

sunny_talwar

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

Best,

Sunny

Not applicable
Author

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

sunny_talwar

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
Author

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: