Hi Team,
Couple of days ago, I posted about a query about calculating the difference between two dates of the same column and with making the use of Lag function. Then I stumbled upon the Lead function instead which helped me in the calculation I was looking for. This is the link of my open query:
Now, since I can have another date column with the help of Lead function, I can correctly calculate the Day Differences. But the next issue I’m having is to put this Day difference field in further Aggregations.
As mentioned in my previous Question, I need to check for how many days my customer spend on each status. I need to have a cumulative sum of all the days spent on each status. For example: CustA spends 8 days on ‘On-Hold’, 0 days on 'Active. CustB spends 3 days on On-Hold and 10 days on Active.
I need to show 2 things on my Chart:
-
I should be able to drag the status on X axis, and put summation of days spend on Value to show as Y-axis. That is: On-Hold: 11 days and Active: 10 days
-
I need to show Average time on each status: As per above example, On Hold Average = 8+3/2 and Active Average: 0+10/2
I have tried number of functions to calculate the sum of Day-Difference with using ‘sum’, ‘sumOver’, ‘runningSum’ but each time either it gives Mismatched aggregation issue or if not then I get ‘Table calculation attribute references are missing in field wells’ error.
Below are some of the logics I’m trying to apply but all giving me same error:
sumOver( {Days Difference}, [{CustomerStatus}] )
avgOver( {Days Difference}, [{CustomerStatus}] )
sumOver( {Days Difference}, [{CustomerStatus}, {Customer_ID}] )
other calculations used are:
Days Difference: dateDiff(min(status_date),{Lead Date},‘DD’)
Lead Date: lead(min({status_date}), [{status_date} ASC],1,[{completed_customers}])
Can this please be helped? Really need to solve it somehow.
Many Thanks!
Regards,