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: 
gerhardl
Creator II
Creator II

Error in Expression Value

Hi There,

In my load script I have an expression like this:

if([Champion Challenge No] = 28 or [Champion Challenge No] = 31,round([Value of first purchase]/20,0.01),

     if([Champion Challenge No] = 29 or [Champion Challenge No] = 32,round([Value of first purchase]/10,0.01), 0)) as [PQ First Purchase Discount],

This means that certain people qualify for a 10% or 5% discount on their first purchase.

Then I have a table where I want to check that the system is correctly posting the expected discount.

Expression 1 is my EXPECTED Discount:      =[PQ First Purchase Discount]

Expression 2 is the actual discount posted     =sum([Trans Amount])*-1

Expression 3 I want to use to look for accounts where the correct discount did not post. So I want to subtract the two expressions from each other, and I am expecting zero values. If teh value is zero I want the field left blank, and otherwise I want to see the value. SO my expression looks like this:

=if([PQ First Purchase Discount]-(sum([Trans Amount])*-1)=0,'',[PQ First Purchase Discount]-(sum([Trans Amount])*-1))

But for some reason, I sometimes do not get a zero value when I subtract the expression, even though the values are the same. See the image attached.

Any ideas?

Gerhard

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try rounding that substraction first:

=if(round([PQ First Purchase Discount]-(sum([Trans Amount])*-1),0.01)=0,'',[PQ First Purchase Discount]-(sum([Trans Amount])*-1))


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try rounding that substraction first:

=if(round([PQ First Purchase Discount]-(sum([Trans Amount])*-1),0.01)=0,'',[PQ First Purchase Discount]-(sum([Trans Amount])*-1))


talk is cheap, supply exceeds demand
gerhardl
Creator II
Creator II
Author

Nice, thank you.

Still don't understand it... but it works.

G