Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Converting string to numbers

Hi:

I am trying to convert a field that can have a possible of 30 number with a max of 15 decimals in QlikView. I am doing,

 

Num(A_Value, '0.0')

Can someone let me know if this is correct

Thanks,

Tak

20 Replies
Not applicable
Author

if you are trying to use that field in expression you can limit it to 2 decimals by changing Number tab in properties....

If you are using to represent only that value into interger than use floor() function.....

Not applicable
Author

I actually need to do a compare to make sure the full values matches another field so I will need to compare on what ever the actuall value is. I am new to QlikView and would appreciate it if you can show me the actual code change base on the below.

Num(A_Value, '0.0')

Thanks,

Not applicable
Author

I actually need to do a compare to make sure the full values matches another field so I will need to compare on what ever the actuall value is. I am new to QlikView and would appreciate it if you can show me the actual code change base on the below.

Num(A_Value, '0.0')

Thanks,

Not applicable
Author

can you attach your qvw file....I am not clear with that requirement.....

Not applicable
Author

I am not sure attaching the qvw will help because we were ask to use a framework that was given to us but I had pasted the scripts below. The key is where I am trying to convert the A_value and B_value. The script is in the transform folder and these values will than be used to compare to each other. Hope this helps to clarify.

 

 

//One tab per dimension

LET vTableName = 'Final_Exchange_Rate'; //!!!What you want to call the table in the QV schema
LET vReloadTimeIn = Now();

[$(vTableName)]:
//!!!Insert Select/Load statement here

LOAD 50 as RECON_ID,

     #keyID,
     A_ID,
    Num(A_Value,'0.0') as A_Value,   /////convert to number with decimal
     B_ID,
     Num(B_Value,'0.0') as B_Value   ////convert to number with decimal
FROM
[..\QVD_Transform\Compare_Exchange_Rate.qvd]
(qvd);

LET vReloadTimeOut = now();

Meta:
LOAD '$(vTableName)' as Table,
NoOfRows('$(vTableName)') as Rows,
NoOfFields('$(vTableName)') as Fields,
'$(vReloadTime)' as ReloadTime,
Interval('$(vReloadTimeOut)' - '$(vReloadTimeIn)','h:m:ss') as ReloadInterval,
1 as LatestFlag
AUTOGENERATE 1;

STORE [$(vTableName)] INTO [..\QVD_Transform\$(vTableName).qvd] (qvd);   ////don't touch this
DROP TABLE [$(vTableName)];

Not applicable
Author

I am not sure attaching the qvw will help because we were ask to use a framework that was given to us but I had pasted the scripts below. The key is where I am trying to convert the A_value and B_value. The script is in the transform folder and these values will than be used to compare to each other. Hope this helps to clarify.

 

 

//One tab per dimension

LET vTableName = 'Final_Exchange_Rate'; //!!!What you want to call the table in the QV schema
LET vReloadTimeIn = Now();

[$(vTableName)]:
//!!!Insert Select/Load statement here

LOAD 50 as RECON_ID,

     #keyID,
     A_ID,
    Num(A_Value,'0.0') as A_Value,   /////convert to number with decimal
     B_ID,
     Num(B_Value,'0.0') as B_Value   ////convert to number with decimal
FROM
[..\QVD_Transform\Compare_Exchange_Rate.qvd]
(qvd);

LET vReloadTimeOut = now();

Meta:
LOAD '$(vTableName)' as Table,
NoOfRows('$(vTableName)') as Rows,
NoOfFields('$(vTableName)') as Fields,
'$(vReloadTime)' as ReloadTime,
Interval('$(vReloadTimeOut)' - '$(vReloadTimeIn)','h:m:ss') as ReloadInterval,
1 as LatestFlag
AUTOGENERATE 1;

STORE [$(vTableName)] INTO [..\QVD_Transform\$(vTableName).qvd] (qvd);   ////don't touch this
DROP TABLE [$(vTableName)];

Not applicable
Author

Num(A_Value, '0.0')

I am using above function it is working fine...

I have A_values as      

0.00002

0.00033

0.02344

0.004455

0.12

when I use          

Num(A_Value, '0.0')

I am getting

0.0

0.0

0.0

0.0

0.1

when I use

Num(A_Value, '0.000')

I am getting

0.000

0.000

0.023

0.004

0.120

This is working fine

                           

Not applicable
Author

How do I get it to ensure that it is comparing what ever it is in the A_value and B_value. If A_value is 1234.333444, I need to ensure that it is comparing what ever maybe in that fields. If I were to use the code that I did, I will only get 4.3.

B_value may have 4.344 and the result would be 4.3 and will consider it to be a match when it should not be.

Num(A_Value, '0.0')

Thanks,

shree909
Partner - Specialist II
Partner - Specialist II

Hi try this

NUM(A_Value ,'#,##0.00') as  A_Value..

if u want 3 decimals replace the last 2 zeros with 3...

or NUM(A_Value ,'#,##0.##')