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: 
Not applicable

Set Analysis function in a KPI

Hi all,

I'm trying to understand why my expression doesn't work.

The expression is:

count( {$<[WeightValue] = {"=if(flag_01 = 1, 0.25, 0)+if(flag_02 = 1, 0.25, 0)+if(flag_07 = 1, 0.25, 0)"} >} ID_Client )

In my table Client there is a column [WeightValue] that has always the value "0.25".

In the same table, i have 3 flags (flag_01, flag_02 and flag_03) which can assume the value 0 or 1.

I need to compare the value of the column [WeightValue] with the sum of the flags (as you can see in the expression).

In this case, I need to check if there are some client that have [WeightValue] = 0.25.


The KPI show me always the value 0 (so I can think that there are no Client that satisfy the equation).

But if I create a Table as ID_Client as Dimension and a Misure trought the funcion

if(flag_01 = 1, 0.25, 0)+if(flag_02 = 1, 0.25, 0)+if(flag_07 = 1, 0.25, 0)

I can see that there are some client that have 0.25 as a result of the function.

The KPI show me the correct value if I select one of ID_Client that satisfy the equation (when getSelectedCount(ID_Client) = 1 and the equation is satisfied).

Can someone help me, please to understand wich is the problem?

Thank you in advance.

16 Replies
antoniotiman
Master III
Master III

Hi Giuseppe,

in Table You have implicit Aggr of Dim ID_CLIENT.

In KPI You need Aggr() function like

Sum(Aggr(Count(Expression),ID_CLIENT))

Regards,

Antonio

devarasu07
Master II
Master II

Hi,

How about using nested if?

count( {$<[WeightValue] = {"=if(flag_01 = 1,0.25,if(flag_02 = 1,0.25,if(flag_07 = 1,0.25,0)))"} >} ID_Client ) 

Not applicable
Author

Ok, but it give me the same result.

After some tests, now the KPI works in a strange way.

If I select (from a filter) only the ID_Client that satisfy the equation, the KPI shows the exact value.

For example, if I select 5 ID_Client that has [WeightValue] = F(x), it shows 5.

But if I select 5 ID_Client that satisfy the equation, and only one ID_Client that doesn't satisfy the equation, the KPI shows me 0. It think was correct if it shows 5, not 0.

Some ideas?

Not applicable
Author

Hi -

antoniotiman
Master III
Master III

Set Analysis is evaluated once per object..

I think You need If() instead of Set Analysis in Your expression.

devarasu07
Master II
Master II

Hi,

Can you share your mock app and expected output. Tks

Not applicable
Author

Sorry, but I can't share the app.. there are data that i can't show.

Anonymous
Not applicable
Author

Try if this helps:

count( {$<[WeightValue] = {"$(=if(flag_01 = 1, 0.25, 0)+if(flag_02 = 1, 0.25, 0)+if(flag_07 = 1, 0.25, 0))"} >} ID_Client )

Anonymous
Not applicable
Author

I'm not sure I understand the problem, but it sounds like you just need a count of clientIDs where only 1 of the 3 flags is set to 1. I'm assuming that based on your if statement:

If that's the case the easiest what to accomplish this is to just create a new field in the script.

Here's what it would look like in the script:

flag_01 + flag_02 + flag_07 as CountWeightFlag

Then your set analysis would look like this:

Count({<CountWeightFlag={1}>}ID_Client )


If you don't have access to the script you can accomplish like this:


count({<flag_01={1}, flag_02={0}, flag_07={0}>}ID_Client ) + count({<flag_01={0}, flag_02={1}, flag_07={0}>}ID_Client )  + count({<flag_01={0}, flag_02={0}, flag_07={1}>}ID_Client )