Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Setting conditions for an average field

Hi guys,

I'm trying to do an average of a field if a condition is met .

I've tried this but its not working any ideas where im going wrong !

This is the original statement  which works fine :

Avg($(vFactor1))-1/3

I wanted to include something to only do the average where Wave =vWaveCurr

I tried this and it was not working 😕

Avg($(vFactor1) and Wave = vWaveCurr )-1/3

10 Replies
israrkhan
Specialist II
Specialist II

try like this..


Avg({<Wave = {"=$(vWaveCurr) }" >} $(vFactor1)-1/3) or


if(Wave = $(vWaveCurr), AVG($(vFactor1)-1/3)), null )

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

    =If(Wave = vWaveCurr, Avg($(vFactor1)) - 1/3)

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hi Guys I tried both for Isrars one it was coming up with error in set modifier ad hoc element '.' or ')' expected  do I need to add something to it ?

jonathandienst
Partner - Champion III
Partner - Champion III

To debug further, you will need to explain what is in vFactor1 and vWaveCurrent.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Thanks vFactor1 is one of the fields we are using just contains ranking scores, vWaveCurrent is set in initial page to the latest wave of data/

israrkhan
Specialist II
Specialist II

Dear Sarah

sorry, i could not understand, can you please share sample document,

i am sure i can help you....

Not applicable
Author

Hi Guys, this is kinda what Im trying to do I wanted a separate expression for each wave vWaveCurr and vWavePrev like in the text box but keeps falling down not sure why

israrkhan
Specialist II
Specialist II

see the expression are working, and you can modify accordingly..

nam
Former Employee
Former Employee

Firstly your variables are incorrect.

vFactor1=Heading 1

Heading 1 has values 1,2 3 so the above will return you null so will not work

so firstly change vFactor1=avg(Heading).

anyway just change the expression in the textbox to :

=avg({<Wave={$(vWaveCurr}>} Heading1)