Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
dipanjan93
Contributor
Contributor

Issue in Expression Editor

Hello Community,

 

I have used the below logic to convert String datatype to Float inside Expression Builder of tMap - 

(row36.Spillover_km3 == null || row36.Spillover_km3.isEmpty() == true)?0  :Float.valueOf(row36.Spillover_km3) 

but I'm getting the below error - 

Exception in component tMap_13 
java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1842)
at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
at java.lang.Float.parseFloat(Float.java:451)
at java.lang.Float.valueOf(Float.java:416)

 

Can anyone please let me know how to rectify this issue?

 

For reference I have attached the job screenshot.

 

Thanks in advance!

 

Best Regards.

Labels (3)
1 Solution

Accepted Solutions
TRF
Champion II
Champion II

@dipanjan93, does this help?

If so, thanks to mark your case as solved (Kudos also accepted as a bonus)

View solution in original post

8 Replies
manodwhb
Champion II
Champion II

@dipanjan93,

can you try the below one.

 

(row36.Spillover_km3 == null || ("").equals(row36.Spillover_km3))?0  :Float.valueOf(row36.Spillover_km3) 

dipanjan93
Contributor
Contributor
Author

Hi @manodwhb

 

I have tried your approach but the issue still persists. 

TRF
Champion II
Champion II

What about this one:

(row36.Spillover_km3 == null || 
("").equals(row36.Spillover_km3.replaceAll(" ", ""))) ? 0.0f : Float.valueOf(row36.Spillover_km3)
manodwhb
Champion II
Champion II

@dipanjan93,since you might have space issue use the below way.i have tested below one working as expected.

 

 

(row1.Col == null || ("").equals(StringHandling.TRIM(row1.Col)))?0  :Float.valueOf(row1.Col) 

 

dipanjan93
Contributor
Contributor
Author

Hi @TRF

 

Nope still the issue persists. Although now something new has come up -

 

java.lang.NumberFormatException: For input string: "null"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
at java.lang.Float.parseFloat(Float.java:451)
at java.lang.Float.valueOf(Float.java:416)

TRF
Champion II
Champion II

The field contains the string "null" (4 characters). Write line this:
(row36.Spillover_km3 == null || ("null").equalsIgnoreCase(row36.Spillover_km3 ||
("").equals(row36.Spillover_km3.replaceAll(" ", ""))) ? 0.0f : Float.valueOf(row36.Spillover_km3)
TRF
Champion II
Champion II

@dipanjan93, does this help?

If so, thanks to mark your case as solved (Kudos also accepted as a bonus)

dipanjan93
Contributor
Contributor
Author

Many Thanks @TRF and @manodwhb for your prompt response! It solved the issue.