
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Count Null by Set Analysis
Hi Guys,
I am trying to count Null in expression and using the below statement. but did not get luck to resolve it. I tried couple of different way by set analysis. Could you please advise me about this?
=Count({$<Year=, Month=, Sale ={'=Len(Trim(Sale))=0'} , YearMonth={">=$(=Date(MonthStart(AddMonths(Min(SaleDate),0)),'YYYYMM'))<=$(=Date(MonthStart(AddMonths(Max(SaleDate),0)),'YYYYMM'))"}>} Sale)
Kind regards
Farrukh
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try something like this:
=Count({$<Year=, Month=, UniqueIdenfierFieldHere = {"=Len(Trim(Sale))=0"} , YearMonth ={">=$(=Date(MonthStart(AddMonths(Min(SaleDate),0)),'YYYYMM'))<=$(=Date(MonthStart(AddMonths(Max(SaleDate),0)),'YYYYMM'))"}>} Sale)
Or you can create a flag in the script
LOAD Sale,
If(Len(Trim(Sale)) = 0, 1, 0) as SaleFlag
...
and then use like this:
=Count({$<Year=, Month=, SaleFlag = {1}, YearMonth ={">=$(=Date(MonthStart(AddMonths(Min(SaleDate),0)),'YYYYMM'))<=$(=Date(MonthStart(AddMonths(Max(SaleDate),0)),'YYYYMM'))"}>} Sale)


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you provide the sample QVW file?


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You could try something like this:
=Count({$<Sale -={'*'}>} Sale)
For testings without further conditions to simplify the approach and avoiding potential errors in other parts - and using from normal selections to reduce the amount of data respectively to emulate the conditions.
But are there really NULL's within the field Sale? If Sale is an field from a common transaction-table there will be quite probably just no records instead of records with NULL. To visualize NULL's is often quite complex - a very good starting point could you find here: NULL handling in QlikView.
- Marcus

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try something like this:
=Count({$<Year=, Month=, UniqueIdenfierFieldHere = {"=Len(Trim(Sale))=0"} , YearMonth ={">=$(=Date(MonthStart(AddMonths(Min(SaleDate),0)),'YYYYMM'))<=$(=Date(MonthStart(AddMonths(Max(SaleDate),0)),'YYYYMM'))"}>} Sale)
Or you can create a flag in the script
LOAD Sale,
If(Len(Trim(Sale)) = 0, 1, 0) as SaleFlag
...
and then use like this:
=Count({$<Year=, Month=, SaleFlag = {1}, YearMonth ={">=$(=Date(MonthStart(AddMonths(Min(SaleDate),0)),'YYYYMM'))<=$(=Date(MonthStart(AddMonths(Max(SaleDate),0)),'YYYYMM'))"}>} Sale)


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try
=Count({$<Year=, Month=, Sale ={'=isnull(Sale)=-1'} , YearMonth={">=$(=Date(MonthStart(AddMonths(Min(SaleDate),0)),'YYYYMM'))<=$(=Date(MonthStart(AddMonths(Max(SaleDate),0)),'YYYYMM'))"}>} Sale)
If a post helps to resolve your issue, please accept it as a Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Sunny,
Could you please advise me related to UniqueIdentifierField, I am using couple of dimensions, eg (MonthYear, Region, Company, Distrct). or do I need to use one of the dimension as an uniqueidentifierfield.
Farrukh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am looking for a field which uniquely defines each row in your fact table? If you don't have any, you can create one using
LOAD RowNo() as UniqueIdentifier
Taking a step back, why are you trying to remove null sales from your Sum(Sale)? Sum(Sale) would never include any sales which are null? What is the goal here?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Sunny,
Its sorted.
Farrukh
