Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Create a new Function

Hi,

I would like to create a new function that I can use to display in a statistics box. Basically the function would do this equation:

(Total No. Hours) x (Hourly Rate) = Total Service Pay

I was trying this lines on the script but can't seem to make it work.

Sum([# of Hours]) as TotalHours

Sum([# of Hours])*[Hourly Rate] as TotalServicePay

I guess making a function is better. So I can display it on a statistics box.

forums.PNG

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi Charles,

Try this on the Statistics Box

Sum(Aggr(Sum([# of Hours]*[Hourly Rate]),[Personnel Name]))

Regards!!

View solution in original post

11 Replies
migueldelval
Specialist
Specialist

Hi Charles,

Could you attach your script?

Regards

Miguel del Valle

Digvijay_Singh

When you use Aggregation functions in script you need Group By clause in the load statement, can you share your script code to understand and also share what problem you are facing.

syukyo_zhu
Creator III
Creator III

Hi, if you do this on your script?

([# of Hours])*[Hourly Rate] as TotalServicePay

juleshartley
Specialist
Specialist

We really need to see the whole load statement to understand where the problem lies...

Digvijay_Singh

Something like this -

Load     A,

           Sum(B) as B1,

          Sum(C) as C1,

          D

from test.qvd

group by A,D;

juleshartley
Specialist
Specialist

ps. An immediate issue is that you are not aggregating the 'Hourly rate' field... you need to multiply before the sum (adding dimensions etc. in group by clause and load)

Load

sum(Pay) as Total Pay

...

;

Load

[# of Hours]*[Hourly Rate] as Pay

...

Not applicable
Author

Hi Everyone,

Thanks for your response. Attached is here is the script. I was trying to add these lines at the end of the script. Not sure if I'm doing it right.

DataResults:

LOAD [# of Hours]

Sum([# of Hours]) as TotalHours,

Sum([TotalHours])*[Hourly Rate] as TotalServicePay;

Anonymous
Not applicable
Author

Hi Charles,

Try this on the Statistics Box

Sum(Aggr(Sum([# of Hours]*[Hourly Rate]),[Personnel Name]))

Regards!!

Not applicable
Author

Hi Manuel,

Thanks! It worked. Aggr( ) did the job.