Hello!
I am trying to sum a column in a collection with a condition.
I have a collection: 'WerkbonPos_col' . Then I create a new collection, based on the previously mentioned collection. Line numbers are added to this, among other things.
Now I want the sum of the 'Werktijd' (working hours), where the condition must be the 'Personeelsnummer' (employee number).
The formula gives me the total sum of all lines, independent of the employee number.
Im trying this:
// Behandelen van de werken
Clear(WerkbonPOS_col_Indexed);;
ForAll(
WerkbonPOS_col;
Collect(
WerkbonPOS_col_Indexed;
Patch(
Last(
FirstN(
WerkbonPOS_col;
CountRows(WerkbonPOS_col_Indexed) + 1
)
);
{
Lijnnummer: (CountRows(WerkbonPOS_col_Indexed) + 1) * 10;
Totale_km: Sum(Filter(WerkbonPOS_col;Personeelsnummer = ThisRecord.Personeelsnummer);Km);
Totale_uren: Sum(Filter(WerkbonPOS_col; Personeelsnummer = ThisRecord.Personeelsnummer);Werktijd);
Documentnaam: "P" & ThisRecord.Personeelsnummer & "N" & var_werkbonnummer & "D" & Concat(
Split(
var_werkbon_datum;
"/"
);
Result
);
WerkbonKey: "P" & ThisRecord.Personeelsnummer & "N" & var_werkbonnummer & "D" & Concat(
Split(
var_werkbon_datum;
"/"
);
Result
)
}
)
)
);;
Everything works except following lines:
Totale_km: Sum(Filter(WerkbonPOS_col;Personeelsnummer = ThisRecord.Personeelsnummer);Km);
Totale_uren: Sum(Filter(WerkbonPOS_col; Personeelsnummer = ThisRecord.Personeelsnummer);Werktijd);
Part of 'WerkbonPos_col':
Personeelsnummer | Werktijd |
079 | 2 |
079 | 3 |
323 | 3 |
What I have after the code ('WerkbonPos_col_Indexed'):
Personeelsnummer | Werktijd | Totale_uren |
079 | 2 | 8 |
079 | 3 | 8 |
323 | 3 | 8 |
What I want:
Personeelsnummer | Werktijd | Totale_uren |
079 | 2 | 5 |
079 | 3 | 5 |
323 | 3 | 3 |
Can someone tell me what I'm doing wrong?
Thank you in advance!
Solved! Go to Solution.
Hi @Arne_R ,
Best Regards,
Levi
If I 'hard-code' the 'Personeelsnummer to 079, it works for employee 079.
Totale_km: Sum(Filter(WerkbonPOS_col;Personeelsnummer = "079");Km);
Totale_uren: Sum(Filter(WerkbonPOS_col; Personeelsnummer = "079");Werktijd);
Example:
Part of 'WerkbonPos_col':
Personeelsnummer | Werktijd |
079 | 2 |
079 | 3 |
323 | 3 |
What I have after the code ('WerkbonPos_col_Indexed'):
Personeelsnummer | Werktijd | Totale_uren |
079 | 2 | 5 |
079 | 3 | 5 |
323 | 3 | 5 |
What I want:
Personeelsnummer | Werktijd | Totale_uren |
079 | 2 | 5 |
079 | 3 | 5 |
323 | 3 | 3 |
Hi @Arne_R ,
Best Regards,
Levi
Thank you. The code works for me. I adapt it to suit my needs.
Kind regards
Arne
User | Count |
---|---|
156 | |
91 | |
67 | |
63 | |
62 |
User | Count |
---|---|
211 | |
157 | |
96 | |
86 | |
76 |