Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
gerrycastellino
Creator III
Creator III

Question on aggr/if in alternate state

=if(not(isnull(only({[s_Hier_Comp2]} fieldA))),

aggr(only({<ASSET_CLASS=P({s_Hier_Comp1}) * P({s_Hier_Comp2})>} ASSET_CLASS), ASSET_CLASS),

aggr(only({<ASSET_CLASS=P({s_Hier_Comp3}) * P({s_Hier_Comp4})>} ASSET_CLASS), ASSET_CLASS)

)

I have the above statement in an expression for a list box.

I need to apply a union of 2 alternate(s)  based on my if condition (if there is a value for fieldA.

There seems to be some syntax issues in this, need to re-structure my aggr/if

Gerry

10 Replies
ramoncova06
Partner - Specialist III
Partner - Specialist III

change your "not" to 0

=if((isnull(only({[s_Hier_Comp2]} fieldA))) = 0

Clever_Anjos
Employee
Employee

Trying to understand your requirement...

gerrycastellino
Creator III
Creator III
Author

HI

Clever Anjos &lt;span class=&quot;icon-status-icon icon-mvp&quot; title=&quot;Mvp&quot;&gt;&lt;/span&gt; &lt;span class=&quot;icon-status-icon icon-partner&quot; title=&quot;Partner&quot;&gt;&lt;/span&gt; wrote:

Trying to understand your requirement...

Clever:  I'm just trying to execute different aggr()  clauses based on if there is a fieldA selected in my list box or not.

ramoncova06
Partner - Specialist III
Partner - Specialist III

in that case use this

=if(getselectedcount([s_Hier_Comp2]) >0,

aggr(only({<ASSET_CLASS=P({s_Hier_Comp1}) * P({s_Hier_Comp2})>} ASSET_CLASS), ASSET_CLASS),

aggr(only({<ASSET_CLASS=P({s_Hier_Comp3}) * P({s_Hier_Comp4})>} ASSET_CLASS), ASSET_CLASS)

)

gerrycastellino
Creator III
Creator III
Author

did not work,  I suspect I have to combine the if within the aggr,  but running into syntax structure issues, with building it correctly... 😞

ramoncova06
Partner - Specialist III
Partner - Specialist III

you don't need to include the if in the aggr, I assumed you had already validated the expressions

the easiest way to identify to find if an field is selected is by using getfieldselections or getselectedcount

gerrycastellino
Creator III
Creator III
Author

getselectedcount/getfieldselections does not seem to work with alternate states.

ramoncova06
Partner - Specialist III
Partner - Specialist III

can you have multiple selections ? or only one ?

ramoncova06
Partner - Specialist III
Partner - Specialist III

and the getselected does work if you set the object state to the same one as the field that you want looking at