Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

number multiply by null value return 0?

Hi all,

    I have done a test. I have data like below :

load * inline

[pack,Inv,price

1,10,12

2,20,10

3,30,

];

Notice that there is no correspond price for pack '3'.

I have 2 straight tables and the dimensions are both 'pack'.

Chart A has only 1 expression: Amount: sum(Inv*price)

Chart B has 2 expression: Amount:sum(Inv*price)  and Target: 30.

This is the outcome:

Capture.PNG.png

I am curious because in table B, Amount for pack '3' is 0 but not '-' (for null).

This will mislead users that the inventory of pack 3 is 0.

I want to show '-' in this case.How to fix it?

Many thanks!

1 Solution

Accepted Solutions
tresesco
MVP
MVP

That is because of sum(), If there is a one-to-one relationship(like in your example) you could use use instead:

=Inv*price      // without sum

View solution in original post

7 Replies
ali_hijazi
Partner - Master II
Partner - Master II

in Chart A go to presentation tab and uncheck suppress zero values

or update your expression to sum(aggr(sum(Inv*Price),Pack))

I can walk on water when it freezes
PrashantSangle

Hi,

Write change your expression for Calculating Amount to

AGGR(SUM(Inv*Price))

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
tresesco
MVP
MVP

That is because of sum(), If there is a one-to-one relationship(like in your example) you could use use instead:

=Inv*price      // without sum

PrashantSangle

Hi,

You can also write like

if(isnull(Inv) or isnull(Price),'-',Sum(Inv*Price))

or

if(isnull(Inv) or isnull(Price) or len(trim(Inv))=0 or len(trim(Price))=0,'-',Sum(Inv*Price))

Or

if(len(trim(Inv))>0 and len(trim(Price))>0,Sum(Inv*Price),'-')

or

if(not isnull(Inv) and not isnull(Price),Sum(Inv*Price),'-')

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
stigchel
Partner - Master
Partner - Master

Or use

sum({<price={'>0'}>}Inv*price)

Not applicable
Author

use this

If(isnull(Inv) or Isnull(Price) or len(trim(Inv))=0 or len(trim(Price))=0,'-',Sum(Inv*Price))

Not applicable
Author

Thank you all, there are many ways to solve this issue as you have proposed. I think tresesco told the truth.

It return 0 because i used 'sum'.  Thank you very much.