Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
alanwong1178
Contributor III
Contributor III

set zero value as null in table

I created a table show sales  in million for 2021 and 2020.

First column is dimension:  [SALES_DATE.autoCalendar.Month].

Second column is set analysis : 
Sum({<[SALES_DATE.autoCalendar.Year] = {'2021'}>}SALES)/1000000

Third column is set analysis :

Sum({<[SALES_DATE.autoCalendar.Year] = {'2020'}>}SALES)/1000000

 

alanwong1178_0-1627287452767.png

 

May I know how can I present data as below for 2021 column. As I have imported data until Jun21 , I would like show all the data after Jun 21 as null to avoid misunderstanding to user that sales for JUL21 is 0

alanwong1178_1-1627287869601.png

 

Please consider the fact that I have a filter [SALES_DATE.autoCalendar.YearMonth] , I would like to ignore this filter and keep all the value for future month as null

 

 

Labels (4)
3 Replies
stevejoyce
Specialist II
Specialist II

Start the expression with an if-statement condition.

I will assuming sum(Sales) could be 0 in some scenarios, so to determine null, you can use the date or count record of Sales/count record of Sales that are > 0.

1) If( num([SALES_DATE.autoCalendar.Month]) <= num(month(today())), Sum({<[SALES_DATE.autoCalendar.Year] = {'2021'}>}SALES))

2) If(Count({<[SALES_DATE.autoCalendar.Year] = {'2021'}, SALES ={">0"} >}SALES) > 0,  Sum({<[SALES_DATE.autoCalendar.Year] = {'2021'}>}SALES))

 

alanwong1178
Contributor III
Contributor III
Author

 

1) For first expression , it works well if no value is selected in filter : [SALES_DATE.autoCalendar.YearMonth]

But my wish is to ignore this filter so that if any value selected in this filter will not affect the result in the table. This means no matter user select anything in [SALES_DATE.autoCalendar.YearMonth], it shows data from year start to current month.

I tried to modify the expression but it does not work as i wish

If( num([SALES_DATE.autoCalendar.Month]) <= num(month(today())), Sum({<[SALES_DATE.autoCalendar.Year] = {'2021'},[SALES_DATE.autoCalendar.YearMonth],[SALES_DATE.autoCalendar.Month]>}SALES))

 

alanwong1178_0-1627351437035.png

alanwong1178_1-1627351587145.png

 

alanwong1178_2-1627351865238.png

 

2) For second expression , this does not work because consider that there is 0 value for Feb21 in my case, so this will be null . I would like to be if it is between year start to current month , it shows sales and 0 if null. If it is greater than current month , then it shows null()

 

 

 

 

stevejoyce
Specialist II
Specialist II

Ignore the same fields in your if-condition.  Without it, months not in your selection will all return null and result will display null.

If( num({<[SALES_DATE.autoCalendar.YearMonth],[SALES_DATE.autoCalendar.Month]>} [SALES_DATE.autoCalendar.Month]) <= num(month(today())), Sum({<[SALES_DATE.autoCalendar.Year] = {'2021'},[SALES_DATE.autoCalendar.YearMonth],[SALES_DATE.autoCalendar.Month]>}SALES))