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: 
Not applicable

string to integer?

Hi,

I have a field 'space used'. This is either in MB or GB.

data looks like this:

3123MB

10GB

1400MB

12GB

I want to display the entire column in terms of GB. So i have to convert my MB data to GB. Just dividing by 1024 doesnt work since Qlikview considers this to be a string.

How can i do this?

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

How about:

=alt(num#(F1, '0MB')/1024

  ,num#(F1, '0GB')+0

  , F1)

-Rob

http://robwunderlich.com

View solution in original post

5 Replies
rbecher
MVP
MVP

Hi,

this should help:

data:

LOAD * INLINE [

    F1

    3123MB

    10GB

    1400MB

    12GB

];

result:

load if(right(F1,2)='MB', Num#(Mid(F1, 1, Len(F1)-2))/1024, Num#(Mid(F1, 1, Len(F1)-2))) as [space used]

Resident data;

- Ralf

Astrato.io Head of R&D
Not applicable
Author

Hi Ralf,

So i was hoping to change this in the expressions column of the graph. How should i enter this in the IF statement?

This is what i am working with right now:

if (wildmatch (space_used = '*MB')>0), space_used * (1/1024), space_used)

so this says that is you find MB then divide by 1024 else display as it is.

Not applicable
Author

even this doesnt work: if(wildmatch(gp_rss_ram,'*M')>0, (Len(gp_rss_ram)-2)*(1/1024),gp_rss_ram)

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

How about:

=alt(num#(F1, '0MB')/1024

  ,num#(F1, '0GB')+0

  , F1)

-Rob

http://robwunderlich.com

Not applicable
Author

This worked: if(wildmatch(gp_rss_ram,'*M')>0,num#(gp_rss_ram, '#M')/1024,num#(gp_rss_ram,'#G'))