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

How to ignore unselected field states in if statement

Right now I have a text box which displays using the following condition:

=If(Round(Sum(ObligatedAmount/1000),1000)=Round(Sum(Amount),1000) and Max(fiscal_year)<2014,0,1)

It works great, but unfortunately this means it displays not only when fiscal_year is greater than 2014, but also when there simply isn't a selection, like right when the QlikView document opens.  How do I get it to ignore when fiscal_year is unselected?

1 Solution

Accepted Solutions
vgutkovsky
Master II
Master II

Try this: If(Round(Sum(ObligatedAmount/1000),1000)=Round(Sum(Amount),1000) and (Max(fiscal_year)<2014 or GetSelectedCount(fiscal_year)=0),0,1)

View solution in original post

9 Replies
vgutkovsky
Master II
Master II

You can add another simple condition: getselectedcount(fiscal_year)>0

Regards,

Vlad

Not applicable
Author

Like this?

=If(Round(Sum(ObligatedAmount/1000),1000)=Round(Sum(Amount),1000) and Max(fiscal_year)<2014 and GetSelectedCount(fiscal_year)>0,0,1)

That doesn't seem to work for me.

vgutkovsky
Master II
Master II

Try this: If(Round(Sum(ObligatedAmount/1000),1000)=Round(Sum(Amount),1000) and (Max(fiscal_year)<2014 or GetSelectedCount(fiscal_year)=0),0,1)

Not applicable
Author

Yep!  That worked!  Thanks Vlad!

Not applicable
Author

Ugh, for reasons unrelated to the construction of the equation that function no longer works.  Now I'm trying to make the following:

IF(1.01>Absolute Value((Sum(ObligatedAmount/1000)/Sum(Amount))>.99 and Max(fiscal_year)<2014,0,1)

How do I achieve the Absolute Value condition?

swuehl
MVP
MVP

Using fabs() function?

Not applicable
Author

I'm getting an error in expression message for the following:

=if(1.01>fabs(Sum(ObligatedAmount/1000)/Sum(Amount))>.99 and Max(fiscal_year)<2014,0,1)

That said, fabs(Sum(ObligatedAmount/1000)/Sum(Amount) is returning a correct value.  It's just not behaving according the the above statement - I'll get values of 1.000000004 which still display.

swuehl
MVP
MVP

Ah, I overlooked that you probably want something like this

=If(

     1.01> fabs( Sum(ObligatedAmount/1000) / Sum(Amount) )

               and

     fabs( Sum(ObligatedAmount/1000) / Sum(Amount ) ) >.99

               and

     Max(fiscal_year)<2014

,1

,0

)

Not applicable
Author

Thanks swuehl!  Had a few tweaks to get around some data-based nonsense, but it looks like we've got it under control now.