I have created a table that contains the time spent on some tickets, so I need to make a sum of this time, but I need to change some data based on the following criteria:
If the ticket is duplicated, I need to do a time average and then use this number for the total sum.
If the ticket is not duplicated but has more than 12 hours, then convert that number to 5 hours.
If the ticket is not duplicated and does not have more than 12 hours using the hours reported.
This image is an example of what some data looks like:
The problem is that I need to see the hours per week, so when I remove the issue_key column, the sum is not done correctly
The table should look like this
This is the custom field I did, but It only works when I have the issue_key column and I’m not sure if this problem can be solved from a calculated field.
ifelse(
count({issue_key})>1,avg({hours_in_status})*distinct_count({issue_key}),
count({issue_key})=1 AND sum({hours_in_status})>10, 5,
sum({hours_in_status}))
The issue is arising because you want to see if the issue_key is a duplicate for the particular issue_key.
When you take away the break down of issue_key from the table count({issue_key}) is looking at all of the issue_key’s not counting the duplicates of each one.
This can’t be done via a calculated field without you having to reference the issue_key in the table.
I would suggest moving this logic to SQL. For this logic you would need to see if the issue key is a duplicate and flag that. And take you’ll need the avg of that issue_key if it’s a duplicate.
This can be done with a countOver / avgOver and partition by the issue_key in SQL.
First I take the minimum hours from the issue_key, with this I can fix the problem of duplicates (previously the solution was the average of the hours), and then I can apply the correction for the high hours. Finally, I just need to apply the arithmetic operation I want.