Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
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

Re: Calculation in script and number format

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

2 Replies
joshabbott
Contributor III

Re: Calculation in script and number format


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.

Re: Calculation in script and number format

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

Community Browser