Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
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

1 Solution

Accepted Solutions
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

View solution in original post

25 Replies
sunny_talwar

Does this alone works fine? -> $(vNewVariance)

cbaqir
Specialist II
Specialist II
Author

Yes

sunny_talwar

What is the output of $(vNewVariance)? Can you share a screenshot?

Mark_Little
Luminary
Luminary

Hi,

What do you see with what Sunny asked.

I just tested this simply with a variable with a minus in and then wrapped in FAB() and it works fine for me.

Mark

cbaqir
Specialist II
Specialist II
Author

12-10-2015 12-35-19 PM.jpg

Variance is $(vNewVariance). Forecast Accuracy is where I can't get the expression to work.

Anonymous
Not applicable

Could you post a qvw? It can better help understand the situation.

Mark_Little
Luminary
Luminary

Hi,

have you formatted the percentage on the table or is it actually returning 60.9%?

If the percentage sign is in the variable it maybe treated as a string.

Mark

cbaqir
Specialist II
Specialist II
Author

Sample QVW attached.

cbaqir
Specialist II
Specialist II
Author

The variable is not formatted with the percentage. It returns -0.6088... The formatting is done within the table.