Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Analysis <= expression

Hi, I have what I think is a really simple question here, but just can quite get it right. I want to use a calculation as part of my set analysis (line 3 below) but know I've got the syntax wrong on line 3

count({<UNIT.STOCKSTATUS={'sold'},
BUYER.B_NO={"*"},
UNIT.M_MILEAGE <= [Avg. Mileage]+15000
>}
UNIT.TOTALSOLD)

I'd be really grateful if anyone could point me in the right direction, thanks

7 Replies
ramoncova06
Partner - Specialist III
Partner - Specialist III

whenever using < or > in your set analysis you have to use advanced search  so instead of just being <= you have to do  {"<=$(=([Avg. Mileage]+15000))"}

this expression should work

count({<UNIT.STOCKSTATUS={'sold'}, BUYER.B_NO={"*"},UNIT.M_MILEAGE = {"<=$(=([Avg. Mileage]+15000))"}

>}

UNIT.TOTALSOLD)

anbu1984
Master III
Master III

Set analysis calculates at Table level and not row level. Use If like below

count( {<UNIT.STOCKSTATUS={'sold'},BUYER.B_NO={"*"} >}

If(UNIT.M_MILEAGE <= [Avg. Mileage]+15000,UNIT.TOTALSOLD)

)

Not applicable
Author

Hi, thanks for the suggestions.

[Avg. Mileage] is the name of an expression in the same table which is:

=avg({<UNIT.STOCKSTATUS={'sold'}>} UNIT.M_MILEAGE)

If I replace [Avg. Mileage] with a number I can get this to work

                        

count({<UNIT.STOCKSTATUS={'sold'}, BUYER.B_NO={"*"},UNIT.M_MILEAGE ={"<=$(([Avg. Mileage] +15000))"}>} UNIT.TOTALSOLD)

          

but when I use  [Avg. Mileage] or if I do this it doesn't work.

count({<UNIT.STOCKSTATUS={'sold'}, BUYER.B_NO={"*"},UNIT.M_MILEAGE = {"<=$(=(
avg({<UNIT.STOCKSTATUS={'sold'}>} UNIT.M_MILEAGE)
+15000))"
} >} UNIT.TOTALSOLD
)

anbu1984
Master III
Master III

You can't do row level calculations or use name of another expr inside set analysis. You can try using If statement as in my above post

Not applicable
Author

Hi, thanks, unfortunately when I use the expression above I just get 0's

timsaddler
Creator III
Creator III

Hello

Try calculating ={"<=$(([Avg. Mileage] +15000))"}>} as a "variable" and then introducing that into the set analysis?

anbu1984
Master III
Master III

Can you post sample app