12 Replies Latest reply: Dec 18, 2014 9:29 AM by Rob Wunderlich

# 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

• ###### 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.

• ###### Re: if statement work only if a value is selected

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

• ###### 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é

• ###### 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.

• ###### Re: if statement work only if a value is selected

Can you post your qv app

• ###### 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;

• ###### 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

• ###### 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

• ###### 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

• ###### Re: if statement work only if a value is selected

i want valmaternité takes 1 for a period of one year begining from mindate. that's all

• ###### Re: if statement work only if a value is selected

looks to me that your code is doing the job on that:

if(IsNull(mindate),2,if(Date>=mindate and Date<=AddYears(mindate,1),1,0)) as valmaternité

up to you to validate valmaternité values.

• ###### Re: if statement work only if a value is selected

Does each row of your chart point to more than 1 valmaternité value? If so, you'll need to use an aggregation like max(valmaternité) to tell your expression which one to use.

-Rob