Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Aggr fuction with If Conditoins

Hi,

I have the following formula, that gives me the number of KN_ID´s under the If-Conditions. I Need the "Distinct" keyword. because otherwise there would be duplictates.

Count(Distinct If(
                             (K1 > vLimit_K1    and  Date = vDate and (

                                                                                                   K2 >  vLimit_K2    or     K3 < vLimit_K3

                                                                                                 )

                              )

                              KN_ID,0))-1

Now I want to Sum a field (KN_IA), which is linear (every KN_ID has exactly one KN_IA) to KN_ID but just for the KN_ID´s, which I get with the IF-Expression.

I tried to do this with Set Analysis, but I am done with that. For some reasons it is not possible in my case.

Therefore I thought of doing that using Aggr-function. The Expression should look somehting like this:

Sum(Aggr(

Sum(KNE_IA),

If(   K1 > vLimit_K1    and  Date = vDate and (  K2 >  vLimit_K2    or     3 < vLimit_K3 )  ),  KN_ID)

))

To sum it up: I want to create a temporary table using aggr function. In that table should be only the KN_ID´s which meet the if-conditions and the belonging KN_IA values. And in this Table I want to sum the KN_IA.

In the Load Script it would be easy to create a new field, which just consists of the needed values for KN_ID, but I use variables and therefore that will not be possible.

I am looking forward to a response. Thank you in advance.

Best regards

thorqlik

12 Replies
sunny_talwar

Its difficult to know without testing it out. So I think testing on your end would be important. Let us know what you find

Not applicable
Author

After Testing it, I can confirm that your solution works to solve the Problem I described.

Again thanks a lot for that.

Unfortunately I just got a new requirement for which this solution will not work, because I have to sum a different Field than KN_IA, that differs in its values for KN_ID.

I have made a new post on that stating the Problem in more detail .

Not applicable
Author

But if I change the variable Values in the app after running the script, the fields, which I calculated in the script, would not Change their values depending on the actual variable value or would they ?