Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Add sign (+/-) using formatting

Hi,

I was wondering if it is possible to add - using formatting options - a leading + or - depending on the value of the number.

I know one can achieve it like this:

=if(num(5)<0,'-','+') & '5'

which should return "+5".

(e.g. 5 should ofcourse be a dynamic field).

Thanks!

Maarten

1 Solution

Accepted Solutions
pennetzdorfer
Creator III
Creator III

use =num(5, '+ #.##0,00; - #.##0,00; +/- 0,00')

The order of format-code parts is positive / negative / 0

Regards,

Florian

View solution in original post

8 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Yes its possible, but more on depends on the requirement.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

It needs to be done in a text box... holding a complex expression.

Because I don't want to evaluate the result (number; postive or negative) twice (one for getting the sign, and one for displaying the actual value) I wanted to use a formatting option (if available).

Hope this makes things a bit more clear.

Thanks!

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     But when you evaluate the expression, it will show the '-' negative sign if the value is negative and for positive no sign.

     Then why you need to calculate sign separately.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
pennetzdorfer
Creator III
Creator III

use =num(5, '+ #.##0,00; - #.##0,00; +/- 0,00')

The order of format-code parts is positive / negative / 0

Regards,

Florian

Not applicable
Author

Hi Florian,

That is exactly the result I was looking for.

Evaluating the expression once, and getting a plus or a minus sign.

Thanks!

Maarten

Not applicable
Author

Hi guys,

I think Florian was able to supply me what I need.

All solutions where '5' was put more than once in the expression might have been good, but I wanted to avoid evaluating '5' multiple times (as '5' should be replaced by a complex expression in reality).

Thanks to all for your very fast responses!

Kind regards,

Maarten

Not applicable
Author

I needed to see the + as well (which is by default not displayed for postive numbers).

Not applicable
Author

Just use one simple format - below will add a + for positive numbers, and leave the - for negative numbers:

So use: num(5, '+#,##0.00')