Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculation in script and number format

I have two questions.

1) I have a field that comes in as 199.00 instead of 1.99 so I put it as an expression in a chart and divided it by 100 to see it as 1.99 but I want to see this as a percent so when I set it as a "Fixed to 2 decimals" and "Show it as a percent" , it shows me 199.00%. Any way to fix this in the expression calculation or script? I want to be able to see 1.99%

1) Is there an easy way to do a sum calculation in the script?  I have a field that is extracted in seconds but I need it in hours. So I want to be able to calculate this in the script for performance reasons. The below seems to be unacceptable. How can I do this in the script without making it overly complicated?

Load

     Speed,

     Speed/2600 as [Speedhours],                                    // doesn't seem to get the right answer

     SUM(Speed/3600) as [Speed in hours],                    //  doesn't work, errors

     Otherfields,

     Otherfields1,

From **

1 Solution

Accepted Solutions
MarcoWedel

Hi,

LOAD

  Num(field1/100, '0.00%') as field1,

  Speed,

  Speed/3600 as [Speed in hours]

Inline [

field1, Speed

199.00, 10

];

QlikCommunity_Thread_129827_Pic2.JPG.jpg

QlikCommunity_Thread_129827_Pic1.JPG.jpg

hope this helps

regards

Marco

View solution in original post

2 Replies
joshabbott
Creator III
Creator III


1 - Try dividing it by 10,000 instead

2 - In order to do sum's (aggregations), you need to group by all the fields that are not part of the sum.

So add:

Group By

  Speed,

  Otherfields,

  Otherfields1

That way you can sum at the correct level.

MarcoWedel

Hi,

LOAD

  Num(field1/100, '0.00%') as field1,

  Speed,

  Speed/3600 as [Speed in hours]

Inline [

field1, Speed

199.00, 10

];

QlikCommunity_Thread_129827_Pic2.JPG.jpg

QlikCommunity_Thread_129827_Pic1.JPG.jpg

hope this helps

regards

Marco