Formula using Sum product calculate total hours in overlapping date array - excel

Please help,
I want to calculate the actual downtime per each type of equipment and per each type of work order, as shown in the following table sample of the data which extend in real file to 6000 rows:
Data table
, when I use this formula:
{=SUMPRODUCT((COUNTIFS(K2:K6000,"<"&MIN(K2:K6000)+ROW(INDIRECT("1:"&ROUND((MAX(L2:L6000)-MIN(K2:K6000))*1440,0)))/1440-1/2880,L2:L6000,">"&MIN(K2:K6000)+ROW(INDIRECT("1:"&ROUND((MAX(L2:L6000)-MIN(K2:K6000))*1440,0)))/1440-1/2880,G2:G6000,"*"&P3&"*",A2:A6000,"PRMN")>0)+0)/60}
I take a long time to calculate as I use it for 6000 rows with extra 2 criteria, so how I can improve this formula to be faster?
Best Regards,
Mahmoud Hazem

Related

Excel - Sum of data at equal intervals

I have some time series longitude latitude data which I am trying to sum up for each month. ( 4 x column headings Time, long, lat, precipitation).
Is there a way of summing data automatically for regular intervals or do I have to manually update the sum equation code cell?
Any help would be hugely appreciated.
Many thanks
I have tried summing it manually but due to large data mass this will take along time.
You can very easily find the month number of a date, using the =Month() worksheet function. Adding such a column might give you the possibility to use the basic "Subtotals" feature of Excel, as you can see in this screenshot:

Averaging specific range of data with loop in excel vba

I have a temperature data taken in every second (1Hz).
I want to reduce this data to minutes combined with averaging every 60 seconds of data. Which will be look like this.
I have tried moving average and other things but it didn't work. Is there any VBA code that i can approach my goal or any spesific function.
My time data range is [A3] - [A88739] and data range is [B3] to [B99739]
I will be waiting for your answers.
Thank you!
I think easier way would be using a helper column.
This will work only if your time data is always like the one you've posted and if the last 6 chars are .XXXXX where X can be letter or numbers, but leading dot is critical
My formula in column C is =VALUE(SUBSTITUTE(LEFT(A3;LEN(A3)-6);".";"/"))
Then with Pivot Table you can group your data by day,hour and minute, and get the average.
Setup of My Pivot Table:
Field Helper into rows section, and grouped by days, hours and minutes
Field Temp into values section, and choose average instead of sum up

Statistical functions on non-numerical value

I am not looking for any code or formula but a rationale/logic.
Background: My data set comes in Date/Time format where a new timestamp is created for each new occurrence of an event.
My goal is to calculate number of occurrences within each hour for a given day. Unfortunately, system does not capture number if occurrences per period as integers. So I have count the number of time an hour value appears within the hour i.e number of times 4 o'clock hour appears. I am currently using Pivot Table in Excel to count the number of times each hour appears. Fields in Rows are hour and dates, and field in Values is count of hour.
Trouble is that I cannot use any summarize functions to get stuff like sum, min, max, percentile, and standard deviation. For example, changing count to sum will only add up all hours. So sum of 4 o'clock hour will return 12 instead of 3. So I am having to use array formulas on pivot table to give me max and min etc.
If I was to use this data in data viz tools like Tableau or Power BI. I won't be able to get very far. I am looking for a suggestions/workaround that can allow me to manipulate my data in a way so it can be used in Pivot Tables in Excel and in data viz tools.
I know my questions is not specific to one tool but I am looking to enhance me understanding of data and data manipulations techniques.
EDIT: Please see attached image
Build a data model, using PowerPivot. Join your fact table to a calendar dimension table. Create a row count measure - you can then summarise that measure to suit (sum, average, min, etc)

Calculating Percent of Total in Power Pivot Model

I have created a power pivot table as shown in the picture. I want to calculate quarter over quarter sales change. For which I have to divide for example corporate family "Acer" 's sales in 2012Q4 by sum of all the corporate family. I am using calculated measure to do this, but I am not sure what formula I can use.
My need is to create two columns, one for 2012Q4 percent of total and one for 2013Q1 percent of total. Then I will create another measure to find the difference. So the formula for 2012Q4 should be like this 1624442 / (1624442+22449+1200+16123) . Any idea which function can help me do it?
It sounds like you are measuring the change in the percent of total for each corporate family from quarter to quarter. You will need to create 3 calculated measures. I'm not sure what your model looks like so I can't give you the exact formula, but here is the idea.
CurrentQtr%ofTotal:= Divide(Sum('Sales'[Units]),Calculate(Sum('Sales'[Units]), All['Product'[Corporate Family])))
PrevQtr%ofTotal:= DIVIDE(CALCULATE(Sum('Sales'[Units]), DATEADD(DimDate[DateKey], -1, QUARTER)),
CALCULATE(Sum('Sales'[Units]), DATEADD(DimDate[DateKey], -1, QUARTER), All('Product'[Corporate Family]))))
Change%ofTotal:= DIVIDE(([CurrentQtr%ofTotal]-[PrevQtr%ofTotal]),[PrevQtr%ofTotal])
I used the divide function because it handles divide by zero errors. You use the ALL function to remove the filter on the Corporate Family column from the filter context. The Change%ofTotal is just to find the differenc. I'm calculating % change but you may just want to subtract.
Here's the link to a good blog post on time intelligence. And here's one on calculating percent of total.
For percentages please follow the tutorial on the Tech on the Net.
Adding another column where you calculate a difference between two pivot columns will not work - this column is "unpivotable", as it relies on a column defintion. You would need to copy and paste pivot as values to another worksheet and do the extra calculation there.

Excel what method use to calculate time and age

I have got a table with 2 columns:
AGE between 10 and 90 lets say :]
and Time (spent on mobiles)
What I need to do is- count how long people spent time on mobiles between 16 and 40.
First part may be seemingly simple because we can count by countif how may people is using mobiles between 16 and 40 but how evaluate spend time on mobiles by the particular age groups.
I will appreciate aaany help
regards
If you need to analyze your data more than creating a static function to count, you may consider using Pivot tables.
Build a simple pivot table with age in rows and time in values. Once this simple pivot table built, you can filter on the rows values, group them together among specific grouping criteria, select specific values by hand, etc.
I like the idea given by Boud of using Pivots but if you specifically want a formula then you can use SumProduct()
=SUMPRODUCT((A2:A13>16)*(A2:A13<40)*(B2:B13))
Do remember to format the cell as [h]:mm:ss since you are adding up times.
SNAPSHOT
You can for example add additional column, with formula like:
=IF ( AND(A1>16, A1<40), B1, 0 )
where A is column with AGE, and B is column with Time, and then simply sum it!

Resources