Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Partner - Specialist III
Partner - Specialist III

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é

View solution in original post

12 Replies
jpenuliar
Partner - Specialist III
Partner - Specialist III

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
Author

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

jpenuliar
Partner - Specialist III
Partner - Specialist III

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
Author

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
Partner - Specialist III
Partner - Specialist III

Can you post your qv app

Not applicable
Author

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
Partner - Specialist III
Partner - Specialist III

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
Author

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
Partner - Specialist III
Partner - Specialist III

                    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