Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
qlikwiz123
Contributor

One Expression...More States

I have a requirement where I need to create an expression where the Expression has to work with Alternate State as well as Default or Inherited State. For example, if I have a List Box1 in Alternate State 1 and List Box2 in Default/Inherited State and the user makes selection on either of the List Boxes, the expression should accept the Filter from both the states. How do I create the Expression with two States in it?

Labels (1)
1 Solution

Accepted Solutions

Re: Two alternate states in one Expression

I guess this

Count({AltState1<[Admin] = {'Admin'}, Month = $::Month*AltState1::Month>}[SerialID])

View solution in original post

9 Replies

Re: Two alternate states in one Expression

May be like this

Sum({<Field1 = AS::Field1, Field2 = $::Field2>}Measure)

Here Field1 will react to Field1 selection in alternate state AS and Field2 will react to selection in default state. This can be further fine tuned based on knowing which state is the object in which we are using this expression. If the object is in default/inherited state, then you can just use this

Sum({<Field1 = AS::Field1>}Measure)

If the object is in alternate state AS, then you can just use this

Sum({<Field2 = $::Field2>}Measure)
qlikwiz123
Contributor

Re: Two alternate states in one Expression

Hi Sunny,

 

My expression is something like this in a Text Box and the Text Box Object is in 'AltState1':

Count({AltState1<[Admin]={'Admin'}>}[SerialID])

 

The expression will react to objects/Filters placed in AltState1. I also have to make the expression react to objects/filters placed in Default or Inherited State. How do I achieve it in this case?

Re: Two alternate states in one Expression

You want all fields from Alternate State and Default/Inherited state to react to this? May be this

Count({AltState1<[Admin] = {'Admin'}>*$<[Admin] = {'Admin'}>}[SerialID])
qlikwiz123
Contributor

Re: Two alternate states in one Expression

Problem is:  I have Month list box which is not assigned to any Alternate state. If  I make any selections on Month list box , my expression is not filtered for selected months.

 

Is there any way I can assign 2 alternate states to this Month list box only as I need my expression to react to AltState1 filters and this Month list box filter which is like a Universal filter.

MVP
MVP

Re: Two alternate states in one Expression

>>Is there any way I can assign 2 alternate states

No. But Sunny's expression will react to selections in the default state and in AltState1.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

Re: Two alternate states in one Expression

I tried this and it seems to work for selection in both Inherited as well as alternate state

=Sum({<Month = $::Month*AS::Month>}Sales)
qlikwiz123
Contributor

Re: Two alternate states in one Expression

Awesome Sunny. Thank you. Could you please tell how to create the same logic in my case since I have specific values for for fields in the expression?

Count({AltState1<[Admin]={'Admin'}>}[SerialID])

Selection Field is Month

I am looking for 'Admin' value in Admin field in this expression. I am a bit lost in framing my expression with your suggested way.

Re: Two alternate states in one Expression

I guess this

Count({AltState1<[Admin] = {'Admin'}, Month = $::Month*AltState1::Month>}[SerialID])

View solution in original post

qlikwiz123
Contributor

Re: Two alternate states in one Expression

Fantastic. Looks like this is working. Will get back if I face an issue. Thanks a lot for being patient and helpful 🙂