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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

What is the best way to select null values in a field? / How do I run a function on or create a subset of a field?

So I started working with qlikview on Monday and 95% of everything seems really intuitive, but I can't figure out how to run a function on a constant selection. I have a computer science background and what I'd love to have is something in the script like this:

const datatype FOO(bar(field));          //field is an array of multiple data types, bar returns datatype.

But I can't figure out how to do that.

Let's start with a description of what I'm doing. I have a calendar object that sets a variable. When that variable changes, it triggers a selection on a set. I want the calendar to have a minimum and maximum date based on the contents of a field.

The field contains date values and null values, and is has the number format of "Date" in document settings. It represents report release dates with a date, and unreleased reports with a null value.

Now, I had it working just fine by setting the min and max on the calendar as "Min/Max({1} FieldName)." But then it broke when I implemented NULLASVALUE, with NullValue = 'NR' in the script, so that I could select unreleased reports.

I've tried changing the min/max to "Min/Max({1<FieldName = FieldName - {NULLVALUE}>} FieldName)," as well as "Min/Max({1<FieldName = FieldName - {NULLVALUE}>})" in hopes that the set expression would qualify as the expression/field in the function syntax.

I've also tried declaring variables in the script ahead of NULLASVALUE with:

LET vCalMax = Max(FieldName);

LET vCalMin = Min(FieldName);

but the variable overview shows the variable value as "Min/Max(FieldName)."

I know it's probably possible to create a new field that only contains the data I want, then set the min/max to "Min/Max({1} NewField).," but that seems inefficient.

So this leaves me with two big questions and one less important question:

What's the best way to select null values in a field?

How do I run a function on or create a subset of a field?

What's the proper way to set a variable using a function in the script?

tl;dr: Field contains dates and nulls. Max({1} FieldName) works until you use NULLASVALUE with NullValue = string. Help?

1 Solution

Accepted Solutions
Not applicable
Author

Well I believe I've found a solution. I've set my Min/Max to "=Max({1} PurgeChar(DateField, 'NullValue'))," which I believe just finds the max of DateField like before, since PurgeChar with 'NullValue' returns DateField with NULL where it was before, which acts just like Max({1} DateField) as I had it before.

Someone correct me if I'm wrong.

View solution in original post

1 Reply
Not applicable
Author

Well I believe I've found a solution. I've set my Min/Max to "=Max({1} PurgeChar(DateField, 'NullValue'))," which I believe just finds the max of DateField like before, since PurgeChar with 'NullValue' returns DateField with NULL where it was before, which acts just like Max({1} DateField) as I had it before.

Someone correct me if I'm wrong.