add negative sign in the data

Six Stars

add negative sign in the data

Hello,

I have a bunch of data in the excel sheet and from talend I read those data and insert into the table. But when the amount is negative it still inserted as a positive number and that's why I am getting the wrong total of amount.


Example :: value = (100) is equivalent to -100.
Negative value comes in ().
I tried this but it's not working.

StringHandling.RIGHT(row27.line, 1).equals("(") ? 
"-" + StringHandling.EREPLACE(row27.line, "(", "") : row27.line 

@TRF Can you please help me out. 


Accepted Solutions
Highlighted
Fifteen Stars TRF
Fifteen Stars

Re: add negative sign in the data

Try this:

row27.line.contains("(") ? "-" + row27.line.substring(1, row27.line.length()-1) : row27.line

TRF

All Replies
Highlighted
Fifteen Stars TRF
Fifteen Stars

Re: add negative sign in the data

Try this:

row27.line.contains("(") ? "-" + row27.line.substring(1, row27.line.length()-1) : row27.line

TRF
Six Stars

Re: add negative sign in the data

@TRF I tried this and it's working fine.

Thanks for your help.

Fifteen Stars TRF
Fifteen Stars

Re: add negative sign in the data

You're welcome


TRF

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch