Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
rdsuperlike
Creator
Creator

Display negative results

Want to display -123 as (123) in expressions

Example:

if ((sum(x) + sum(y) +sum(z)) - (sum(x) + sum(y) +sum(k))) < 0

then i want to display (14000) instead of -14000

Any help is appreciated

18 Replies
petter
Partner - Champion III
Partner - Champion III

=Num(14000,'0;(0)')         will return 14000

=Num(-14000,'0;(0)')         will return (14000)

Or more complete:

=Num(-14000,'# ##0;(# ##0)' , ',' , ' ' )     will return    (14 000)

With decimal separator and thousands separator specified as the third and fourth parameter.

rdsuperlike
Creator
Creator
Author

i didnt understand how to incorporate it into my expression.

can u plz help me?

mrossoit
Creator II
Creator II

Encase your entire expression into fabs() function

=fabs((sum(x) + sum(y) +sum(z)) - (sum(x) + sum(y) +sum(k)))

Regards

MR

rdsuperlike
Creator
Creator
Author

ok...but it returns positive digit if it is negative. But I want to show (14000) if it is -14000

mrossoit
Creator II
Creator II

So the difference is only brackets?

Try this:

if ((sum(x) + sum(y) +sum(z)) - (sum(x) + sum(y) +sum(k)) < 0, '(' & (sum(x) + sum(y) +sum(z)) - (sum(x) + sum(y) +sum(k)) & ')', (sum(x) + sum(y) +sum(z)) - (sum(x) + sum(y) +sum(k)))

It's ugly but will shows (14000).

petter
Partner - Champion III
Partner - Champion III

Then you simply do this:

=Num(  sum(x) + sum(y) + sum(z) - ( sum(x) + sum(y) + sum(k) ) ,  '0;(0)'  )




MarcoWedel

Dual('('&fabs( yourexpression)&')', yourexpression)

rdsuperlike
Creator
Creator
Author

doesnt work for me.

It still gives me negative value.

PrashantSangle

Hi,

did you try peter suggestion,

There is no need of If statement,

Try like

Num((sum(x) + sum(y) +sum(z)) - (sum(x) + sum(y) +sum(k))),,'# ##0;(# ##0)')

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 🙂