Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'm working on a data set I've attached below looking to convert Mb and Kb down to bytes, however I don't really know how to do so do so... I've done it on python but not sure with QlikSense Load Script how can I do the calculation.
Python Code looks somewhat like this:
df1.Size = (df1.Size.replace(r'[kM]+$', '', regex=True).astype(float) * \ df1.Size.str.extract(r'[\d\.]+([KM]+)', expand=False)
.fillna(1).replace(['k','M'], [10**3, 10**6]).astype(int))
With your data "nnS', the process would be to remove the S (scale character) to get the numeric part and multiply by the appropriate scale value. There are numerous ways to write the conditional scale value, but here is perhaps a simple and clear (to me) way.
keepchar(Size, '0123456789') * if(Size like '*M', (1024*1024), if(Size like '*k', 1024, 1))
-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com
Something like:
If Label = 'KB',Value*1024,
If Label = 'MB',Value*1024*1024)) as Bytes
With your data "nnS', the process would be to remove the S (scale character) to get the numeric part and multiply by the appropriate scale value. There are numerous ways to write the conditional scale value, but here is perhaps a simple and clear (to me) way.
keepchar(Size, '0123456789') * if(Size like '*M', (1024*1024), if(Size like '*k', 1024, 1))
-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com