Skip to main content
Announcements
See why Qlik was named a Leader in the 2024 Gartner® Magic Quadrant™ for Data Integration Tools for the ninth year in a row: Get the report
cancel
Showing results for 
Search instead for 
Did you mean: 
madhuparnadhar
Contributor III
Contributor III

Format string as percentage

Hello all,

I am trying to format a string into percentage, but really struggling with Num and Num# functions. Below is the data which I receive from the data source :

Product NameRate
P15.766233766233767
P20.0
P34.247104247104247
P40.0
P54.086538461538462
P64.975124378109453
P70.0
P83.3932135728542914
P90.0
P104.10958904109589

 

I would like the field "Rate" (which is a string) to be formatted as percentage with only two places after decimal (so 5.76% for P1 say). I have to keep the number formatting as Auto, so I need to achieve this by Num/Num# functions.

Can anyone please help me ?

Thanks and Regards,

Madhuparna Dhar

 

Labels (1)
1 Solution

Accepted Solutions
martinpohl
Partner - Master
Partner - Master

Hi,

use this

load
"Product Name",
num(num#(Rate,'#.0############','.',',')/100,'#.## %','.',',') as Rate;
LOAD * INLINE [
Product Name, Rate
P1, 5.766233766233767
P2, 0.0
P3, 4.247104247104247
P4, 0.0
P5, 4.086538461538462
P6, 4.975124378109453
P7, 0.0
P8, 3.3932135728542914
P9, 0.0
P10, 4.10958904109589
];

Regards

View solution in original post

3 Replies
Anil_Babu_Samineni

Perhaps this?

Floor(Rate, '0.01')

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
martinpohl
Partner - Master
Partner - Master

Hi,

use this

load
"Product Name",
num(num#(Rate,'#.0############','.',',')/100,'#.## %','.',',') as Rate;
LOAD * INLINE [
Product Name, Rate
P1, 5.766233766233767
P2, 0.0
P3, 4.247104247104247
P4, 0.0
P5, 4.086538461538462
P6, 4.975124378109453
P7, 0.0
P8, 3.3932135728542914
P9, 0.0
P10, 4.10958904109589
];

Regards

madhuparnadhar
Contributor III
Contributor III
Author

Hi @martinpohl ,

This works perfectly.

Thank you so much for your quick help!

Regards,

Madhuparna