Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Calculated average of in expression

Hi guys,

I'd like to calculate average of string variable.

I have the variable:           Less, the same and More

I'd like to recode them to   -1,           0      and 1   in expression

Is it possible to do it in the expression

Avg(IF(DDD='Less', -1, IF(DDD='the same', 0, IF(DDD='More', 1))) DDD)

Cheers,

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

avg(pick(match(DDD,'Less','Same amount','More'),-1,0,1))

It works

Thanks.

View solution in original post

3 Replies
eduardo_sommer
Partner - Specialist
Partner - Specialist

Try

Avg(Match(DDD, 'Less', 'the same', 'More)-2)

Eduardo

eduardo_sommer
Partner - Specialist
Partner - Specialist

If this doesn't work, do the conversion in the load script.

Eduardo

Anonymous
Not applicable
Author

avg(pick(match(DDD,'Less','Same amount','More'),-1,0,1))

It works

Thanks.