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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Ron1
Partner - Creator
Partner - Creator

Avoiding If for the following Expression

I do not want to add if else in my expression as we are going through some standards.

Please help me to convert the below expression without If

if(GetSelectedCount([Employee])=1,
avg({<Level={3}, [Department Code]={2}, Country={'India'}>} Target),
if (GetSelectedCount(Department)=1,
avg({<Level={2}, [Department Code]={2}, Country={'India'}>} Target),
avg({<Level={1}, [Department Code]={2}, Country={'India'}>} Target)))

1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

Give this a shot

Pick(Match(1, GetSelectedCount([Employee]), GetSelectedCount(Department)) + 1,
Avg({<Level={1}, [Department Code]={2}, Country={'India'}>} Target),
Avg({<Level={3}, [Department Code]={2}, Country={'India'}>} Target),
Avg({<Level={2}, [Department Code]={2}, Country={'India'}>} Target))

View solution in original post

2 Replies
sunny_talwar
MVP
MVP

Give this a shot

Pick(Match(1, GetSelectedCount([Employee]), GetSelectedCount(Department)) + 1,
Avg({<Level={1}, [Department Code]={2}, Country={'India'}>} Target),
Avg({<Level={3}, [Department Code]={2}, Country={'India'}>} Target),
Avg({<Level={2}, [Department Code]={2}, Country={'India'}>} Target))
Ron1
Partner - Creator
Partner - Creator
Author

It works perfectly. Thank you very much.