Skip to main content
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
Not applicable
Author

Hi,

Thanks for the reply. Can't share the actual app, so will create a sample app and share as soon as possible.

Not applicable
Author

Hi,

Yes I am using a Group By clause.

Not applicable
Author

Can you just put below in the script

((max([Phase 2 E_DT]) - max([Phase 2 ST_DT]))/30) as [2_Dur_shyamal]

Just for testing purpose, break the expressions into different columns like below:

[Phase 2 ST_DT],

((max([Phase 2 E_DT]) - [Actual C_DT])/30) as FirstPart,

((max([Phase 2 E_DT]) - max([Phase 2 ST_DT]))/30) as SecondPart

Not applicable
Author

Hi,

Thanks for the reply.

I tried splitting up the column into 2 parts and it gives me values per the split expression.

But when I try using it with "If" condition it evalutes "Else" part incoreectly.

Not applicable
Author

Can you please create a sample app. That will help you get your answer quick. For now, we all are guessing.

Not applicable
Author

Hi Everyone,

I have created a sample app and to my surprise it works fine, exactly as I wanted except for the negative value (for Test4).

PFA the sample file.

Any suggestion why this would not work in a bigger scenario is really appreciated.


salto
Specialist II
Specialist II

Hi Shyamal,

are the values in the sample file (I mean in the "problematic" column) the same as in the real environment?

Regards!

Not applicable
Author

yes, I created exact replica of values in all the columns as in actual file.

andy_2013
Contributor
Contributor

Try this sample

brijesh1991
Partner - Specialist
Partner - Specialist

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