Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

"Else" part not working

Hi All,

This might be something very simple, but can't get it to work, don't know why.

I have if-else calculation and many more like the same in my script, when I am pulling the columns in a straight table (alongwith few other columns), what I observed is, qlikview won't show me the results from else part even though the condition is fulfilled for it.

For Ex:

if (isnull([Phase 2 ST_DT]), ((max([Phase 2 E_DT]) - [Actual C_DT])/30), ((max([Phase 2 E_DT]) - max([Phase 2 ST_DT]))/30)) as [2_Dur_shyamal]

It will show the value [2_Dur_shyamal] only when [Phase 2 ST_DT] is null, otherwise it will be blank.

On the other hand, if I am using these calculations individually as expressions, it works fine.

But I would like to have all these calculations done in script rather in expressions

Any ideas on this?

32 Replies
sudeepkm
Specialist III
Specialist III

Hi,

SALTO's provided solution is the best practice to handle null. Have you tried "not isNull()", instead of isNull.

It is just the other way. If it is not null what to do else what to do, you may also check the blanks.

like [Phase 2 ST_DT] = ''

I do not have any specific reasons to advice using not isnull() but that is still an option.

sujeetsingh
Master III
Master III

See this sample

miikkaqlick
Partner - Creator II
Partner - Creator II

I think that reason is in your datamodel.

First try this:

If( IsNull( [Phase 2 ST_DT] ) ,1,0) as [2 Dur...]

This way you can verify that Isnull and If-functions are working.

Next step is to use verify calculations in if-statement.

Hopefully this will help.

Br,

Miikka

kiranmanoharrode
Creator III
Creator III

Try this will work,

IsNull([Phase 2 ST_DT]), ((max([Phase 2 E_DT]) - [Actual C_DT])/30), ((max([Phase 2 E_DT]) - max([Phase 2 ST_DT]))/30) as [2_Dur_shyamal]

Anonymous
Not applicable
Author

Hi Shyamal,

  here my suggestion like first check what ever the null your writing.

Like =if(isnull([Phase 2 ST_DT]) or len([Phase 2 ST_DT])=0,1,0) AS Test Flag

suppose above one writing 1 and 0 means you have null value,

after do one thing take table box add what ever the else fields are using and then select a  Test Flag=1 then check your fields values are getting side by side or differently.

according to my understand like both are not getting in side by side values.

like.

X Field NameY field Name
100-
200-
-0.25
-.36

        

thanks

shaik

Not applicable
Author

Hi,

Yes tried, still it somehow always goes to the part where [Phase 2 ST_DT] = 0 and displays that value only.

Not applicable
Author

Still the same result

Not applicable
Author

Hi All,

I have tried all the possible things (Atleast I think so!!!) but still can't get this thing working.

Now, i have replaced "IsNull" with  "Len(Trim())" as suggested by SALTO but with the same result.

Any help would be greatly appreciated!!

salto
Specialist II
Specialist II

Hi Shyamal,

can you please provide a sample file with the ([Phase 2 ST_DT]) fields' real values?

Thanks!

Colin-Albert

Do you have a Group By clause in the load script?

If you are using an aggregation function in the load script, you will need to group the data for that load section.