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: 
tas_taba1
Contributor III
Contributor III

Multiple conditions inside if statement

Hello Qlikkers,

In my application I have multiple filters and tables. But the measures of my tables change with the kind of filter value selected. For example-

image-1image-1

Right now, the expression for calculating SE is-

"=if(getselectedcount(CinemaRx)=0,
(sqrt(Sum(ALL Aggr(
Sqr(Sum(UtilityWt)-(Sum(TOTAL <CinemaStratum> UtilityWt)/Count(DISTINCT ALL <CinemaStratum> CinemaPSU))) * (Count(DISTINCT ALL <CinemaStratum> CinemaPSU)/(Count(DISTINCT ALL <CinemaStratum> CinemaPSU)-1))
, CinemaPSU, CinemaStratum)))/4),
(sqrt(Sum(ALL Aggr(
Sqr(Sum(UtilityWt)-(Sum(TOTAL <CinemaStratum> UtilityWt)/Count(DISTINCT ALL <CinemaStratum> CinemaPSU))) * (Count(DISTINCT ALL <CinemaStratum> CinemaPSU)/(Count(DISTINCT ALL <CinemaStratum> CinemaPSU)-1))
, CinemaPSU, CinemaStratum)))))"

But I also need to add another condition inside the if statement. If getselectedcount(CinemaRx) OR getselectedcount(CinemaNumber) either of them is 0 then I want the the first expression to be executed. I tried the following expression but it is not working-

"=if(getselectedcount(CinemaRx)=0 OR getselectedcount(CinemaNumber)=0,
(sqrt(Sum(ALL Aggr(
Sqr(Sum(UtilityWt)-(Sum(TOTAL <CinemaStratum> UtilityWt)/Count(DISTINCT ALL <CinemaStratum> CinemaPSU))) * (Count(DISTINCT ALL <CinemaStratum> CinemaPSU)/(Count(DISTINCT ALL <CinemaStratum> CinemaPSU)-1))
, CinemaPSU, CinemaStratum)))/4),
(sqrt(Sum(ALL Aggr(
Sqr(Sum(UtilityWt)-(Sum(TOTAL <CinemaStratum> UtilityWt)/Count(DISTINCT ALL <CinemaStratum> CinemaPSU))) * (Count(DISTINCT ALL <CinemaStratum> CinemaPSU)/(Count(DISTINCT ALL <CinemaStratum> CinemaPSU)-1))
, CinemaPSU, CinemaStratum)))))"

i.e. if no value is selected from either of these two filters than the expression must be divided by 4.

Any help regarding this will be highly appreciated. Thank you.

Labels (2)
1 Reply
ArnadoSandoval
Specialist II
Specialist II

Hi @tas_taba1 

It should be working or we need a better explanation of your issue; I downloaded your QVF file, and implemented the condition you described, while adding some visualization objects to view the selections behaviour; I also created a variable vExpression containing your expression, as it is easier to manage the UI, and debug it; I attached v3 of your sample application

dummy_app_v3.png

Arnaldo Sandoval
A journey of a thousand miles begins with a single step.