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: 
Not applicable

How to use Null() into a set analysis expression

Hi , I have this set analysis expression but the values in 'HOTEL_AREA' are Null() so the expression is not filtering as expected.

How could I write correctly the set analysis expression to consider empty or Null() values instead of {''}?

-SUM({<HOTEL_AREA={''},TIPO_EMPRESA={'HOTEL'}>}REAL_PERIODO_USD)

Thank you.

Labels (1)
1 Solution

Accepted Solutions
anbu1984
Master III
Master III

SUM({<REAL_PERIODO_USD={'=Len(Trim(HOTEL_AREA))=0'},TIPO_EMPRESA={'HOTEL'}>}REAL_PERIODO_USD)

View solution in original post

8 Replies
alexandros17
Partner - Champion III
Partner - Champion III

You cannot manage directly null values in set analysis but you can use '*' to set all as you 've done, there is another option, if your HOTEL_AREA field is used as dimension you can exclude nul values by checking the box in the dimension page.

Let me know

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You can try using -={'*'}. A better solution is to replace the nulls in the script with real values.


talk is cheap, supply exceeds demand
anbu1984
Master III
Master III

SUM({<REAL_PERIODO_USD={'=Len(Trim(HOTEL_AREA))=0'},TIPO_EMPRESA={'HOTEL'}>}REAL_PERIODO_USD)

MK_QSL
MVP
MVP

Create one more field in the script just below the HOTEL_AREA

IF(IsNull(HOTEL_AREA) or LEN(TRIM(HOTEL_AREA))=0, 1, 0) as HOTEL_AREA_NULL_FLAG

Now use as below

=SUM({<TIPO_EMPRESA = {'HOTEL'}, HOTEL_AREA_NULL_FLAG  = {'1'}>}REAL_PERIODO_USD)

Not applicable
Author

I wish the easiest solution (HOTEL_AREA-={'*'}) had worked but it doesn't , I do not know why.

The solution "SUM({<REAL_PERIODO_USD={'=Len(Trim(HOTEL_AREA))=0'} " works ok, but I don't understand why, I do not understand its logic but is usefull in this case.

because I have other fields with null vaues, I wonder if there is a syntanxis in script to replace all the "len(trim('any_field))=0" by ''.

Something like:

Table:

load

if(len(trim(*))=0 , '' , * ) as *

from ...

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

You replace nulls in fields in the script by adding these two lines at the start of the script:

NullAsValue *;

Set NullValue = 'NULL' ;


talk is cheap, supply exceeds demand
Not applicable
Author

if u are using "HOTEL_AREA" as dimension ...

just use "supress null values"

anbu1984
Master III
Master III

SUM({<REAL_PERIODO_USD={'=Len(Trim(HOTEL_AREA))=0'} --You will get correct result only when REAL_PERIODO_USD is unique across the rows.

Create ID using RowNo() in script and try this

=SUM({<ID={'=Len(Trim(HOTEL_AREA))=0'},TIPO_EMPRESA={'HOTEL'}>}REAL_PERIODO_USD)

Or

Create flag in script as below and use that in Set Analysis

Len(Trim(HOTEL_AREA)) As HOTEL_AREA_NULL_FLAG

=SUM({<HOTEL_AREA_NULL_FLAG={0},TIPO_EMPRESA={'HOTEL'}>}REAL_PERIODO_USD)