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

How to use if condition on alternate state?

Hi All,

I have one alternate state. STATE1.

There is a field called SourceData in this state.

I want if sourceData = Actuals use expression 1 of alt state else use expression 2 of alt state.

I m using foll. But not working. Please help.

If (SourceData = 'Actuals', sum( {STATE1<REG=$::REG>}Actualamt),sum( {STATE1<REG=$::REG>}Budgetamt) )

1 Solution

Accepted Solutions
whiteline
Master II
Master II

Hi.

Use Only() function to set the state for SourceData:

Only({STATE1<REG=$::REG>} SourceData)

View solution in original post

6 Replies
whiteline
Master II
Master II

Hi.

Use Only() function to set the state for SourceData:

Only({STATE1<REG=$::REG>} SourceData)

Anonymous
Not applicable
Author

It worked perfectly fine. Thanks a lot!!!!

Anonymous
Not applicable
Author

One more question related to it.

It works fine for the expression, but for label if i use the same, it doesnt work.

I want:

if (only({State1}isnull(Fyear)), 'Actuals','Budget')

i also tried:

if (only({State1}getselectedcount(Fyear)=0), 'Actuals','Budget')

But doesnt work. Please guide.

whiteline
Master II
Master II

Switch Only() and isnull().

The logic is that you first aggregate the data using particular set and then check if the result is null or not.

Only() is aggregation function like Sum, Count etc. refer to QV help.

Anonymous
Not applicable
Author

But isnull() does not accept alternate state.

isnull({State1}Fyear)--> error in expression

whiteline
Master II
Master II

Definitely.

But {State1} is a set modifier of Only().

isnull(only({State1} Fyear))

There is no magic. QV has at least two types of functions. Aggregation and regular.