Qlik Community

Qlik Education Discussions

Discussion Board for collaboration related to Qlik Education.

Not applicable

if statement work only if a value is selected

if(valmaternité=1,if ([Code d'entreprise]='12',interval(num(Time#('02:00','hh:mm')),'hh:mm'),interval(num(Time#('01:00','hh:mm')),'hh:mm')))

this expression work only if i selected 1 for valmaternité

any help please

1 Solution

Accepted Solutions
jpenuliar
Valued Contributor III

Re: if statement work only if a value is selected

clearly, valmaternité has other values before selection, if it is a variable you will have to trigger it to 1

if it is a field, it is a null so you definitely need to select 1.

what exactly are you trying to compute with your formula?

I am thinking you  should convert your expression to Set Analysis so you dont have to worry about selecting 1 for valmaternité

12 Replies
jpenuliar
Valued Contributor III

Re: if statement work only if a value is selected

Because that's how If statement works.

If condition is fulfilled, then action, else action....

in your case if you select 1 for valmaternité, your formula will work, just as you mentioned.

Not applicable

Re: if statement work only if a value is selected

so how can i make it work without selecting value??

jpenuliar
Valued Contributor III

Re: if statement work only if a value is selected

clearly, valmaternité has other values before selection, if it is a variable you will have to trigger it to 1

if it is a field, it is a null so you definitely need to select 1.

what exactly are you trying to compute with your formula?

I am thinking you  should convert your expression to Set Analysis so you dont have to worry about selecting 1 for valmaternité

Not applicable

Re: if statement work only if a value is selected

valmaternité is a calculated variable which take 1 if the date is in an interval of time.

i am trying to full the field either of 1 hours or 2 hours and i want it to do this accordind to the date in the table.

jpenuliar
Valued Contributor III

Re: if statement work only if a value is selected

Can you post your qv app

Not applicable

Re: if statement work only if a value is selected

this how i obtain valmaternité:

matable:
LOAD
CNI,
[Nom Prénom],
Date,
Min(if([Maternité (Évènements)]=1,date(Date)))as mindate
Resident Année2013
Group by CNI,[Nom Prénom],Date;
outer Join(matable)
LOAD
CNI,
[Nom Prénom],
if(IsNull(mindate),2,if(Date>=mindate and Date<=AddYears(mindate,1),1,0)) as valmaternité
Resident matable;

jpenuliar
Valued Contributor III

Re: if statement work only if a value is selected

looks like valmaternité is a field not a variable, therefore, upon load, your expression will not return value, or should i day the condition to which your expression was defined is not fulfilled until you make the selection to 1

Not applicable

Re: if statement work only if a value is selected

Valmaternite is not respecting the interval when it takes 1.

how can i correct this??

for my fist question , it work correctly with a set analysis

jpenuliar
Valued Contributor III

Re: if statement work only if a value is selected

                    Valmaternite is not respecting the interval when it takes 1.

                              how can i correct this??

I am not sure how I can help on this without in depth analysis of your work.

JP

               for my fist question , it work correctly with a set analysis

well its great to know that you made it work with SET ANALYSIS.

JP

Community Browser