Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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
Highlighted
Specialist II
Specialist II

Re: "Else" part not working

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!

Highlighted
Not applicable

Re: "Else" part not working

Hi,

Thanks for the response.

I tried the same, but doesn't work.

Highlighted
Specialist II
Specialist II

Re: "Else" part not working

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]



Highlighted
Not applicable

Re: "Else" part not working

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


Highlighted
Specialist II
Specialist II

Re: "Else" part not working

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

Highlighted
Master III
Master III

Re: "Else" part not working

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.

Highlighted
Champion
Champion

Re: "Else" part not working

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

Highlighted
Not applicable

Re: "Else" part not working

There are numeric values.

Highlighted
Not applicable

Re: "Else" part not working

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.