Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
43918084
Creator II
Creator II

invalid expression for if condition for Null value

I have below script that has no problem but ecounter Invalid expression once I add null condition.

Would appreciate experte guidance to make the correction.  Many thanks.

No issue in below script

load Distinct
key,
sum(timeSpentSeconds) as timeSpentSeconds,

if((sum([timeSpentSeconds])/60/60/8)>1,round(sum([timeSpentSeconds])/60/60/8)&'d', frAC(sum([timeSpentSeconds])/60/60/8)*8&'h')as [timeSpent_day_logged]
resident Worklog
group by key;

Drop table Worklog;

Invalid expression in below script

load Distinct
key,
sum(timeSpentSeconds) as timeSpentSeconds,

if(isnull([timeSpentSeconds]),'not specified',(if((sum([timeSpentSeconds])/60/60/8)>1,round(sum([timeSpentSeconds])/60/60/8)&'d', frAC(sum([timeSpentSeconds])/60/60/8)*8&'h')))

as [timeSpent_day_logged]
resident Worklog
group by key;

Drop table Worklog;

 

 

 

Labels (3)
12 Replies
marcus_sommer
MVP
MVP

You may try:

load Key, coalesce(Expr, 'default) as Value from X group by Key;

pravinboniface
Creator III
Creator III

Can you share some data?  This is what I am using and it works for me.

Worklog:
load 
1 as key, Null() as timeSpentSeconds
AutoGenerate(1);
load 
2 as key, 100 as timeSpentSeconds
AutoGenerate(1);

newtab:
NoConcatenate
load Distinct
key,
sum(timeSpentSeconds) as timeSpentSeconds,

if(count([timeSpentSeconds])=0,'not specified',
	(if((sum([timeSpentSeconds])/60/60/8)>1,round(sum([timeSpentSeconds])/60/60/8)&'d', frAC(sum([timeSpentSeconds])/60/60/8)*8&'h')))

as [timeSpent_day_logged]

resident Worklog
group by key;

Drop table Worklog;

exit Script;
43918084
Creator II
Creator II
Author

 Thank a lot to all experts for giving me many solutions.  After many trial and check, I have found that the "-" is because my table was joining another table and some of the value do not exist in the other table

So I use applymap instead and fix the problem.  

Regardless, Thank you so much for your guidance.  I have learned a lot more through the discussion.