1 Reply Latest reply: Sep 9, 2015 6:18 PM by Oleg Troyansky

# Need help with a formula

Hi All,

I have 2 tables

Hourentry:
Project, Employee, Hours
A, Gerton, 8
A, Jeffrey, 6
A, Kim, 1
B, Jeffrey, 4
B, Mike, 5
]
;

Project:
Project, Projectmanager
A, Gerton
B, Mike
]
;

Now I want a table with the following result

 Employee Project Hours total Hours from others on my project Gerton A 8 7 Jeffrey A 6 0 Jeffrey B 4 0 Kim A 1 0 Mike B 5 1 Total - 24 8

Especially the last column I find difficult:

- It should only display the hours on lines where the Employee is the project manager

- It should sum all hours for that specific project, except for the project manager himself

- Employee and project are the dimensions

- It should display the totals on the last row

How do I do that in Qlikview?

Thanks for helping,

Bart

• ###### Re: Need help with a formula

Hi Bart,

here you go - see attached.

The "basic" expression that covers your logic should be:

if(Employee = Projectmanager, sum(total <Project>Hours) - sum(Hours), 0)

Only for Project Managers, get the total of Hours by Project and subtract the Hours spent by the Project manager himself.

However, this formula can only work at the detailed level (by Employee and Project). The total for this expression would be zero. So, it needs to be enhanced with the Advanced Aggregation function AGGR. This way, the results will be pre-calculated at the detailed level and then summarized for the total:

sum(aggr(

if(Employee = Projectmanager, sum(total <Project>Hours) - sum(Hours), 0)

, Employee, Project))

cheers,

Oleg Troyansky