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
salto
Specialist II
Specialist II

Hi,

maybe the problem relies in the IsNull(field) function. I suggest you to use len(trim(field))=0 instead of IsNul:


if (len(trim([Phase 2 ST_DT]))=0, ((max([Phase 2 E_DT]) - [Actual C_DT])/30), ((max([Phase 2 E_DT]) - max([Phase 2 ST_DT]))/30)) as[2_Dur_shyamal]

Hope this helps!

Not applicable
Author

Hi,

Thanks for the response.

I tried the same, but doesn't work.

salto
Specialist II
Specialist II

Hi,

what if we change the conditions order:

if (len(trim([Phase 2 ST_DT]))>0, ((max([Phase 2 E_DT]) - max([Phase 2 ST_DT]))/30 , ((max([Phase 2 E_DT]) - [Actual C_DT])/30))) as [2_Dur_shyamal]



Not applicable
Author

Hi,

In that case it calculates the else part, so no matter what order I keep, it always seems to display the expression for the condition :

[Phase 2 ST_DT] = 0


salto
Specialist II
Specialist II

Which values have you got in that field [Phase 2 ST_DT] ?

sujeetsingh
Master III
Master III

Syamal actually while there is dimension in the chart or graph you are using hense use this condition as

if(sum([2ST_DT])<>0,(max([2E_DT])-max([2ST_DT]))

   ,max([2E_DT])-max(C_DT))

See the sample i have pasted.

vikasmahajan

check for synax as per following expr                        

fabs(SUM({<FinancialYear=,Quarter=,MonthName=>} AGGR(if((Date(vDateForAgeing)-if(isnull(Date([DUE_DATE])),1,Date([DUE_DATE])) >=181),SUM({$<FinancialYear=,Quarter=,MonthName=,[Posting Date] ={"<=$(=MonthEnd(Max([Posting Date])))"}>}[Net Outstanding])),DOC_NO,Customer,Location))

/100000)

HTW

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
Not applicable
Author

There are numeric values.

Not applicable
Author

Hi,

Thanks for your response.

But it's working fine when I am using them in expressions.

My problem is, I want to do all these calculations in script where it is causing issue.