I using Grafana and influxdb to collect ‘product data’ in the assembly line. I make a chat by grafana to show how many products was done in every hour.
It works good, but i have one problem, sometimes the worker will clear the total count because of shifts change. this cause the division data less than 0.
Considering this serial data(each data 10 minutes):
100 200 300 400 0 10 20
the correct time divisional value in this hour should be (400-100) + (20-0) = 320
I tried also search but no help, do you have any ideas? (Sperate to 2 time divisions when data set to 0 is also OK , in this sample, we can get two bars with 300 and 20)
Thanks a lot!
Use different approach with subqueries:
1.) Inner query will calculate diff between each record with NON_NEGATIVE_DIFFERENCE()
-> 100 100 100 0 10 10
2.) Outer query will just SUM() result of inner query and group it per hour -> 320
Related
How to calculate time difference in talend say for example there is variable on_off in database with 0 and 1 i need to find the difference between the time according to on_off condition for some calculation. 0 has 7:15:00 and 1 has 7:30:00 i need to get the difference as 15 minutes using talend.
I am struggling with how to calculate a running balance that is dynamic. Here's what I have.
A range of periods with an intersection between total duration and each month in the duration.
A rate that is applied at each intersection.
An initial amount
A need to calculate a running balance based on the initial amount less the rate applied in that period.
For example, I have a project worth $2,500,000 that is 8 months long. The rates for each interval are as follows: 1. 8.10% 2. 14.04% 3. 26.8% 4. 29.1% 5. 33.4% 6. 30.4% 7. 47.4% 8. 100%
For period 1 I have $202,500 (8.10% × $2.5 million), For period 2, I have $322,500 (14.04% × $2,297,500 ($2.5 - $202,500)), for period 3, I have $530,000 (26.8% × $1,974,999 ($2.5 - sum of first two periods ($525,000)). At the end of period 8, my balance is $0 and my earned amount = $2.5 million.
Can I use something like RunningTotal = Sum(MonthlyAmts) OVER (ORDER BY XX ROWS UNBOUNDED PRECEDING), ORDER BY Period? Or is this a candidate for a cursor?
Thanks in advance!
It depends on your table structure. But it sounds like you should use function. If you would like get all years use table valued function, if you are interested only on result use scalar function. Or better way with recursive CTE.
I have a matrix with several groups(employees, managers and departments). I have columns: sum time expected, sum time entered, sum overtime, sum missing time. At the manager and department level the overtime and missing time skew the results. Basically if a manager has two employees and one has 5 hrs overtime and the other has 5 hrs missing time, the result will show that for the manager there is no overtime or missing time for their employees.. I have tried to add subtotals but I get the same outcome. I have also tried to =sum(textbox.value) but I get the error that aggregates on textboxes have to be within footers. I believe that subtotal rows should be considered footers but that is not the case. Any help would be much appreciated. Thanks!
Time Expected Time Reported OT MISSING-------------------------------------------------------------------
Total by Manager----------------------------------------------------------------------------------------------------------
80 ------------------ 80 --------------- 0 ------ 0--------
Totals by Employee---------------------------------------------------------------------------------------------------------
40 -------------------- 35 -------------- 0-------- 5---------
-----------------------------------------------------------------40 -------------------- 45 -------------- 5 --------0
I realized my problem. My calculations were thrown because I had tried to use isnothing to replace NaN with 0s.
I have the following chart, which uses Quick Table calculation to count the percentage of the values across the group Category for each month.
What I want is to count the percentage of the monthly running total of the values across the group Category for each month. I can create the quick calculation for monthly running total, separately, but I can't seem to combine it with this below because one requires quick calculation across the table and another across the group. Can anyone advise if this is doable?
The workbook attached here, with the problem above in the second tab.
Edit: Let me give example what I meant here:
April: A = 1000, B=500, C= 200, D=300 -> total is 2000
percentage in April in chart is A = 1000/2000 = 50%, B = 25%, C = 10%, D = 15%, total = 100%
May: A=2000, B=2000, C=1800, D=200 ->
cumulative April+May A=3000, B=2500, C=2000, D=500 -> total is 8000
percentage in May in chart is A=3000/8000 = 37.5%, B = 31.25%, C = 25%, D = 6.25%, total = 100%
I got an answer elsewhere and thought I should update here. The solution was to use a secondary table calculation. Basically, after putting SUM(Value) pill in Row:
right click on it to select Add Table Calculation
set as primary calculation the Running Total Sum of Table (Across)
check the box to Perform a secondary calculation on the result
set as secondary calculation the Percent of Total of Table (Down)
See below screenshot of the setting.
Are you looking for ways to calculate the sum of the running total across the category? it is not clear when you say to count the percentage? However if you are looking for sum of percentage running total across your category... you can edit your calculation and set the calculation type as running total, the summarize value ( you can choose, sum , average, min,...max) and the running along option choose category.
I am using Crystal 9 and have created a report showing calls logged by users, time taken to close the call, Solved with (allocated a value to the latter field depending on time taken eg. 1-59 mins = < 1 hr = 1), 60-239 mins = < 4 = 4. I have then grouped the results by users and got totals for each of the Solved values
Solved1 = solved in less than 1 hour
eg group total shows (when record data hidden)
User1 (Total Calls= 74) (Solved1 = 42) (Percentage1 = 56.76)
User2 (Total Calls= 17) (Solved1 = 2) (Percentage1 = 11.76)
Total Calls and Solved1 are obtained using Running Total Fields.
Percentages are Formula fields and calculated as follows:
Percentage1 = Solved1/Total Calls * 100
My problem is that I need to graph the percentage values for each user for each Solved value eg. 56.76 and 11.76 on one chart. This would be easy except that Crystal doesn't let me select this field in the chart option because it's calculated from two Running Totals.
Since some formulas are accepted by the Chart expert and running totals are also accepted, is there a way I can calculate the percentage which it would find acceptable? Or can I put the total and Solved value in the chart and have the chart calculate the percentage somehow? I was looking at using count and I can get the count to count all the records for a single person but not where say the value in a specific field = '1'
eg count (call_id, )/count (call_id, closedby) * 100
Does anyone know how I can write that fomula or any other way of graphing a percentage?
You can do this using Crystal formulas.
Set up a formula for Solved1 - something like
if {myTable.timeTaken} < 60 then 1 else 0
Next, set up a formula for Percentage1 - something like:
100*sum(#Solved1,{myTable.closedBy}) / count({myTable.call_id},{myTable.closedBy})
Drag and drop the formula for Percentage1 onto the report layout, then you should be able to add it from Report Fields onto your graph in the Data tab of the Chart Expert. (You may then want to remove the Percentage1 formula item from the report layout.)
I ran into a similar issue trying to graph On Time Delivery percentages.
I have three percentages to display: On Time, 1-3 days late, and over 3 days late.
I was in need of displaying zero percents as well, i.e. when there were no records that were "1-3 days late" I still needed to show 0% as one of my bars. The above did not address that. I ended using this resolution with a twist.
I created 4 formulas:
one to return 1 if the record was on time else 0
one for the 1-3 days,
one for the over 3 records.
one for each record returning a value of 1.
With that I was able to create my percentage fields using the Sum of one of the first 3 formulas divided by the sum of the "1" formula. Crystal would not work if I used the Count(...) function on a key field. It only worked when using the Sum(...) function in my percentage formulas.