Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
cliff_clayman
Creator II
Creator II

How to format decimal fields in script

I have a few decimal fields from a SQL table that I need to format in the script.  The user does not want to see the decimals where the value is a round number.  For example, currently a value displays as 100.00 and the user wants to see 100.  However, if the value is 123.45, then I need it to display as 123.45.  Can I handle this in the script or do I do it on the report?

1 Solution

Accepted Solutions
Digvijay_Singh

Missed to rename value field -

Load ID,Num(Value) as Value;

Load * inline [

ID, Value

1, 100.00

2, 100.45

3, 90.00

4, 90.10 ];

View solution in original post

5 Replies
Anil_Babu_Samineni

Yes, We can achieve where you want. Would you provide real data to look

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Use the same solution as mentioned here: How to format decimals using a format pattern on a report

vishsaggi
Champion III
Champion III

Hows your SQL decimal field values come through. Are they always two digits after decimal. May be you can try like:

LOAD *,

         IF(Subfield(Values, '.',2) = 0, Round(Values), Values) AS FormattedField

FROM yoursource;

Digvijay_Singh

You can try Num as suggested above in script as well -

Load ID,Num(Value);

Load * inline [

ID, Value

1, 100.00

2, 100.45

3, 90.00

4, 90.10 ];

Capture.PNG

Digvijay_Singh

Missed to rename value field -

Load ID,Num(Value) as Value;

Load * inline [

ID, Value

1, 100.00

2, 100.45

3, 90.00

4, 90.10 ];