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

IsNull function not working in script

Hi Friends,

I am having a Issue with Isnulll function. Some of expert can please help me to resolve this Issue

I am having field called Date.I want to show 0 when there is no Date got selected.

In front end side I am using formula in Text Object if(Isnull(Dates) = -1,0,1) we expected output 0. It's getting as expected.

I have written Same formula in script

Test:

LOAD

Dates,

if(IsNull(Dates)=-1,0,1) as [Date Info]

FROM

xyz.qvw

but [Date Info] is displaying only 1. Not even 0. Just like in below Screen shot

Isnull.PNG

Some can plz help on this. I am attaching sample data and sample qvw

Thank you,

Swarupaaa

12 Replies
sunny_talwar

In the attached sample, there are no places where date is null. Have you tried adding a row where date is actually null?

kruppas78
Contributor III
Contributor III

Hi,

i mean the correct code will be:

if(IsNull(Dates),0,1) as [Date Info]

marcus_sommer

Try it with: if(len(trim(Dates))=0,0,1) as [Date Info]

- Marcus

santiago_respane
Specialist
Specialist

Hi,

if you are trying to display 1 if a value is selected in the Dates field and 0 if there's no value selected you can add a text object with the following formula:

=IF(GetSelectedCount("Dates")>0,1,0)

You don't need to apply that logic in the script.

Please let me know ir this helps.

Kind regards,

sunny_talwar

When I added few nulls in your attached Excel file

Capture.PNG

I see 0

Capture.PNG

For your actual application, you might have white spaces and that's why IsNull isn't working. Try with Len(Trim()) function

If(Len(Trim(Dates)) > 0, 1, 0) as [Date Info]

Not applicable
Author

Hi Sunny,

Is it possible by using len function?. why because my requirement is

if(Dates = "",0,1) so I thought it can be done by using Isnull. Is there any alternate method

Thank you,

Swarupaa

Not applicable
Author

Hi Marcus,

Thanks for Reply. I have tried this but it's not working

Not applicable
Author

Hi Sunny,

Thank you so much for Answer. But in my data there is null values. only if we select only it have to show 1.

beck_bakytbek
Master
Master