Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Highlighted
MaxCld
New Contributor II

Multiple If Conditions in a variable with multiple selection criteria

Hi,

I'm trying to make my app more "ergonomic" with the use of buttons and make the set analysis still "simple" (not to make the if in the set analysis and being redundant).

The first variable vSelectType can be 4 different values Jaune,Vert,Presta and All. Buttons will define the value of vSelectType.

Then in a second variable vType, i try to make a multiple if conditions that will change the selection criteria in my set analysis like :

if($(vSelectType)='Jaune',[Article Vte Famille]={'Bananes'},[Fournisseur Lot Type]=-{'P'},[Fact Ligne Couleur]={'Jaune'},[Fact Type Vente]={'BANANES'},

if($(vSelectType)='Vert',[Article Vte Famille]={'Bananes'},[Fournisseur Lot Type]=-{'P'},[Fact Ligne Couleur]={'Vert'},[Fact Type Vente]={'BANANES'},

if($(vSelectType)='Presta',[Article Vte Famille]={'Bananes'},[Fact Type Vente]=-{'BANANES'},

if($(vSelectType)='All',[Article Vte Famille]={'Bananes'}))))

The set analysis is : sum({$<$(vType)>}[Marge Pds Net])

I think the problem is that Qlik think that the , is part of the if and isn't part of the string to replace, when vSelectType changes.

I tried :

'[Article Vte Famille]={'Bananes'},[Fournisseur Lot Type]=-{'P'},[Fact Ligne Couleur]={'Jaune'},[Fact Type Vente]={'BANANES'}'

"[Article Vte Famille]={'Bananes'},[Fournisseur Lot Type]=-{'P'},[Fact Ligne Couleur]={'Jaune'},[Fact Type Vente]={'BANANES'}"

text([Article Vte Famille]={'Bananes'},[Fournisseur Lot Type]=-{'P'},[Fact Ligne Couleur]={'Jaune'},[Fact Type Vente]={'BANANES'})

It's not working

Anybody has a idea ?

Thank you,

Max

2 Solutions

Accepted Solutions

Re: Multiple If Conditions in a variable with multiple selection criteria

May be try this

If(vSelectType = 'Jaune', '[Article Vte Famille] = {[Bananes]}, [Fournisseur Lot Type] =- {[P]}, [Fact Ligne Couleur] = {[Jaune]}, [Fact Type Vente] = {[BANANES]}',
If(vSelectType = 'Vert', '[Article Vte Famille] = {[Bananes]}, [Fournisseur Lot Type] =- {[P]}, [Fact Ligne Couleur] = {[Vert]}, [Fact Type Vente] = {[BANANES]}',
If(vSelectType = 'Presta', '[Article Vte Famille] = {[Bananes]}, [Fact Type Vente] =- {[BANANES]}',
If(vSelectType = 'All', '[Article Vte Famille] = {[Bananes]}'))))

View solution in original post

Re: Multiple If Conditions in a variable with multiple selection criteria

Can you try this

Sum({$<$(=$(vType))>} [Marge Pds Net])

 

View solution in original post

6 Replies
Partner
Partner

Re: Multiple If Conditions in a variable with multiple selection criteria

Have you tried 

sum({$<$(=vType)>}[Marge Pds Net])

OR

sum({$<'$(=vType)'>}[Marge Pds Net])

It will be easier to help if you could create a sample app where you have some sample data and your variables and expressions.

Plees ekskuse my Swenglish and or Norweglish spelling misstakes

Re: Multiple If Conditions in a variable with multiple selection criteria

May be try this

If(vSelectType = 'Jaune', '[Article Vte Famille] = {[Bananes]}, [Fournisseur Lot Type] =- {[P]}, [Fact Ligne Couleur] = {[Jaune]}, [Fact Type Vente] = {[BANANES]}',
If(vSelectType = 'Vert', '[Article Vte Famille] = {[Bananes]}, [Fournisseur Lot Type] =- {[P]}, [Fact Ligne Couleur] = {[Vert]}, [Fact Type Vente] = {[BANANES]}',
If(vSelectType = 'Presta', '[Article Vte Famille] = {[Bananes]}, [Fact Type Vente] =- {[BANANES]}',
If(vSelectType = 'All', '[Article Vte Famille] = {[Bananes]}'))))

View solution in original post

MaxCld
New Contributor II

Re: Multiple If Conditions in a variable with multiple selection criteria

Hi Sunny_Talwar,

Thank you for your answer,

I removed the $() in the if(vSelectType='Jaune', etc... and put [] around criteria and the if variable is now working !

But I still have problem with the synthax of the primary set analysis : sum({$<$(vType)>}[Marge Pds Net])

I already tried with the new if :

sum({$<$(vType)>}[Marge Pds Net])

sum({$<'$(vType)'>}[Marge Pds Net])

sum({$<'$(=vType)'>}[Marge Pds Net])

sum({$<$(=vType)>}[Marge Pds Net])

Not working

MaxCld
New Contributor II

Re: Multiple If Conditions in a variable with multiple selection criteria

Hi Vegar,

I tried with the new if of Sunny_Talwar :

sum({$<$(vType)>}[Marge Pds Net])

sum({$<'$(vType)'>}[Marge Pds Net])

sum({$<'$(=vType)'>}[Marge Pds Net])

sum({$<$(=vType)>}[Marge Pds Net])

Not working

Re: Multiple If Conditions in a variable with multiple selection criteria

Can you try this

Sum({$<$(=$(vType))>} [Marge Pds Net])

 

View solution in original post

MaxCld
New Contributor II

Re: Multiple If Conditions in a variable with multiple selection criteria

It's working perfectly thank you !!