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

Issue in Expression -Qlikview

Hi,

1)Total Members : 100

Expression Used : = (SUM(IF(FLAG_MEM_PERSON_KEY=1 , FLAG_MEM_PERSON_KEY)))

2)Total Members who lost weight :

=(SUM(IF(FLAG_MEM_PERSON_KEY=1 and $(WeighLoss) < 0   , FLAG_MEM_PERSON_KEY)))

So WeighLoss is a variable that has weightloss value for each Userid.

Problem:

For Total Members who lost weight  i should get a value as 1 (because UserID has a negative value which is less than 0.
But unfortunately this is not happening.
Can you please check the attached qvw .

Error.jpg

1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

    Have a look at the attached application

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

11 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Try this.

     =sum(aggr(SUM(IF(FLAG_MEM_PERSON_KEY=1 and ($(WeighLoss))< 0   , FLAG_MEM_PERSON_KEY)),USER_ID))

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
DavidFoster1
Specialist
Specialist

Lots of issues here:

1)     Use set analysis instead of SUM(IF.... Sorry to be blunt but if you dont know set analysis then you need to stop and learn it.

2)     The problem is you are summing a key field instead of counting them, or have a dedicated field that holds a 1 per person record that can then be used in SUMs.

Your expressions should be

COUNT({$<FLAG_MEM_PERSON_KEY={'1'}>} FLAG_MEM_PERSON_KEY)


COUNT({$<FLAG_MEM_PERSON_KEY={'1'}, WEIGHT_LOSS={"<0"}>} FLAG_MEM_PERSON_KEY)


on the assumption that weight loss is a field.

bbi_mba_76
Partner - Specialist
Partner - Specialist

Hi,

replacing the variable in the expression I found the following error: "nested aggregation not allowed"

richard_chilvers
Specialist
Specialist

Hi

I have taken a quick look, but do not entirely understand how you are calculating the weight loss variable.

However, you may want to check the spelling of your variable shown in green above, which misses the 't' in weight. I don't think it will sort out your problem though

Not applicable
Author

Its not working

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

HI,

What output you are expecting. I am getting 0.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Yea me too,

Because UserID 17 has lost weight(-3).

So here count should be 1.

richard_chilvers
Specialist
Specialist

I agree with David. A small investment in time understanding Set Analysis now using this fairly simple example would be well spent, and help greatly in the future.

best regards

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

    Have a look at the attached application

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!