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: 
cbaqir
Specialist II
Specialist II

FABS with variable?

When I copied this expression into a text box, I see Error: Error in expression: ')' expected.

=IF(($(vForecastRound)=0 and $(vActualRound)=0), IsNull(Null()), IF(FABS($(vNewVariance))>1,0, 1-FABS($(vNewVariance))))

I think the issue is related to FABS($(vNewVariance)) because this alone gives me the same error. Does FABS() not work in this case for some reason?

Thanks,

Cassandra

25 Replies
Anonymous
Not applicable

Put an equal sign in the beginning of the variable for vNewVariance

=IF($(vVariance)=0,0,IF($(vForecastRound)=0,IF($(vVariance)<0,-1,1), ($(vVariance)/ ($(vForecastRound))))).

Sounds silly but should work!

Anonymous
Not applicable

Do this for all of your variables. From your sample it seems thats the issue. Let me know if it works.

sinanozdemir
Specialist III
Specialist III

Hi,

I added "=" in vNewVariance variable. Can you check if it is producing the expected results.

Capture.PNG

Capture.PNG

cbaqir
Specialist II
Specialist II
Author

As pointed out to me by an earlier response, having the = causes issues such as:

https://community.qlik.com/message/931044?et=watches.email.thread#931044

12-9-2015 8-26-05 AM.jpg

cbaqir
Specialist II
Specialist II
Author

See above.

sinanozdemir
Specialist III
Specialist III

I needed to test the below approach and it seems to be working so you need this FABS($(=$(=vNewVariance))). The calculated variable needs to be calculated as well.:

Capture.PNG

Capture.PNG

Hope this helps.

Thanks

cbaqir
Specialist II
Specialist II
Author

Sinan,

Thanks for the help but I am still a little confused. The original issue was that my Forecast Accuracy was not displaying. The expression in the chart is =$(vNewForecastAccuracy) and the variable expression is =IF(($(vForecastRound)=0 and $(vActualRound)=0),IsNull(Null()),IF(FABS($(vNewVariance))>1,0,1-FABS(($(vNewVariance))))) . Even if I update this to =IF(($(vForecastRound)=0 and $(vActualRound)=0),IsNull(Null()),IF(FABS($(=$(=vNewVariance)))>1,0,1-FABS($(=$(=vNewVariance))))) , it doesn't look right.

What am I missing?

The vNewVariance expression is defined as IF($(vVariance)=0,0,IF($(vForecastRound)=0,IF($(vVariance)<0,-1,1), ($(vVariance)/ ($(vForecastRound))))) .

12-11-2015 1-39-09 PM.jpg

Thanks,

Cassandra

sinanozdemir
Specialist III
Specialist III

This is the expression in the forecast accuracy column:

Capture.PNG

Is the expression correct? It seems like the columns are not available any longer.

cbaqir
Specialist II
Specialist II
Author

No, I was playing with that expression to try to get it to work. It is normally populated with =$(vNewForecastAccuracy)

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

The general problem you are dealing with is the comments in your variables. The comments will get included in the expansion. So for example:

myvar = 1+1  // comment

=fabs($(myvar))

expands to:

=fabs(1+1) // comment)

Notice the right paren for fabs() is now after the comment -- a syntax error. Remove the comments from your variable defs and it will work.

How do I debug this? Remove the label from the Forecast Accuracy Expression. Now the column heading shows the expanded expression, and you can examine the full syntax.

-Rob

http://masterssummit.com

http://qlikviewcookbook.com