Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I am trying to convert string to number.
Below values are coming in as string and I want to convert into number. When I use num() in backend it gives no values.
Can anyone help me?
Thanks
Hi,
Try to multiply the field by 1.
Your_Field * 1
Hope this helps
Hi,
Num#(Field)
Could be hidden characters that you don't see.
Try
Trim(Your_Field)*1 as YourNumberField
or
num#(trim(Your_Field))
or
num(trim(Your_Field))
Actually I just took a closer look at your numbers.
Is the decimal point supposed to be a comma?
Or is the comma supposed to not be there?
Hi,
try changing your script like:
SET ThousandSep='.';
SET DecimalSep=',';
hope this helps
regards
Marco
if you want to keep your default separator settings though, you might as well load the Amount field like:
table1:
LOAD Num#(Amount,'#.##0,00',',','.') as Amount
INLINE [
Amount
"1.083,79"
"1.084,85"
"1.100,88"
];
hope this helps
regards
Marco
You can use this in the load script:
Num#(PurgeChar(Amount,','),'#.#####') as Amount
Num() is for formatting a number as text (changing the text representation) and Num#() is interpreting a text as number (changing the numeric representation).
Yes, that is correct. QV is usually excellent at (automatically) determining the correct format to use. In this case, using Num# will ensure that it's interpreted correctly (as a number) - just in case the decimal point and proceeding comma cause an issue. This should ensure that the field can be used in expressions.