Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
rassanbekov
Partner - Contributor
Partner - Contributor

Very Interesting task for scripting

Hello, guys!

Very intersting task for Qlikview scripting.

I have data set for ''project code'', "hours", "rate"  and "realization" rate.

The income is recognized when hours x rate x realization.

However, the realization changes over time.

When the realization changes the income is recongized by last available realization.

The formula should aggregate the value like "hours" ((1) x "rate" (1) + "hours" (2) + "rate" (2)) x realization (2). something like this.

I include the input data. Please propose any script.

Kind regards,

Ruslan

17 Replies
vinieme12
Champion III
Champion III

Would you be able to post some dummy data that best represents your scenario and the expected output?

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
vinieme12
Champion III
Champion III

How to get answers to your post?

Qlik Community Tip: Posting Successful Discussion Threads

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
rassanbekov
Partner - Contributor
Partner - Contributor
Author

Inputting data.

The output should look like

Job codeMonthResult
123June5 x 10 000 x 30%
456June6 x 10 000 x 30%
789June7 x 10 000 x 30%
123July(5 x 10 000 + 8 x 10 000) x 40%
456July(6 x 10 000 + 10 x 10 000) x 40%
789July(7 x 10 000 + 11 x 10 000) x 40%
rassanbekov
Partner - Contributor
Partner - Contributor
Author

posted

effinty2112
Master
Master

Hi Ruslan,

Data:

LOAD Month,

     Employee,

     [Job code],

     HRS,

     Rate

FROM

data.xlsx

(ooxml, embedded labels, table is Sheet1);

Left Join(Data)

LOAD Month,

     [Job code],

     Realization

FROM

[data 2.xlsx]

(ooxml, embedded labels, table is Sheet2);

Job code Month HRS*Rate*Realization/100
123June15000
123July32000
456June18000
456July40000
789June21000
789July

44000

Regards

Andrew

rassanbekov
Partner - Contributor
Partner - Contributor
Author

Thank Andrew. But the task is not about simple multiplication.

The formula to be written in a way to add up previous monthes and current month and multiply total to current realization rate.

It reminds me aggregation function. But I cannot set up correct formula.

Please consider that option.

Kind regards,

Ruslan

effinty2112
Master
Master

Hi Ruslan,

     Sorry - did not read carefully enough. will respond

Andrew

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Your expression could be something like (this is in the UI, the script can be built using GROUP BY and a similar expression)

=Sum(HRS * Rate) * FirstSortedValue(Realization, -RealizationMonthStart)

The only thing you need to add when reading the Realizations, is to convert the month (in what year is this month anyway) into a MonthStart() date value and call it RealizationMonthStart.

Best,

Peter

rassanbekov
Partner - Contributor
Partner - Contributor
Author

Thank you, Peter!

I changed input "month" into date format. And loaded script as MonthStart (Month) into script editor. Then I just copied your expression but it didn't work out.

Is it possible if you share qvw file, where you test your expression?

Kind regards,

Ruslan