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

error in expression

Hello,

I am writing this expression in Resident table, but it is throwing me an error:

SUM([FARE]+ [TAX])+ SUM(IF([DOCTYPE]='2',(-1*fabs(IsNull([MEAL AMOUNT]),0)), fabs(IsNull([MEAL AMOUNT]),0)))

AS [TOTAL FARE], 

Please suggest.

Regards,

Balraj

7 Replies
Michiel_QV_Fan
Specialist
Specialist

SUM([FARE])

+ sum([TAX])

+ SUM(

IF([DOCTYPE]='2',

(-1*fabs(IsNull([MEAL AMOUNT]) =-1,0)),

fabs(IsNull([MEAL AMOUNT]) =-1,0)))

maxgro
MVP
MVP

fabs has 1 parameter

Anonymous
Not applicable
Author

what do you want to achive/to sum?

isnull(MEAL_ACCOUNT) is a condition and Returns -1 or 0

sum(-1*fabs(MEAL_ACCOUNT) if MEAL_Count is null? _1*0 = 0 can be achieved easier

Anonymous
Not applicable
Author

RUDOLF,

MY MENTIONED EXPRESSION THROWING A SYNATX ERROR, THESE ARE THE SOME PARAMETER TO ACHIVE SOME RESULT IN BUSINESS.

CORRECT ME IF I AM MAKING ANY MISTAKE IN EXPRESSION.

Anonymous
Not applicable
Author

As Massimo said, function fabs() has one parameter.  You're trying to use two, this is your syntax mistake.

As for the business - I don't understand your third sum.  What are you trying to calculate here?

jduenyas
Specialist
Specialist

isnull in TSQL like   ISNULL(a,b) returns b if a is null

But it is not in QlikView which is like the IsNull in Basic, Isnull returns True or False (-1 or 0)

Besides, Fabs requires only one parameter and returns the Absolute value Fabs(-20) = 20

jduenyas
Specialist
Specialist

Your IsNull([MEAL AMOUNT]),0) should read like so:

If(IsNull([MEAL AMOUNT), 0, [MEALAMOUNT])