Selectively copying a data list in Excel - excel

I'm looking to selectively copy a list of data in Excel for the purposes of reducing the quantity.
In the first column I have Date/time and in the second column I have a data value, in this case it's electrical meter readings.
The data is currently given very 15 minutes and what I'm trying to do is reduce that to every hour. i.e. effectively create a new column which extracts only the data from the original list for every hour (Also with no gaps in the rows, therefore condensing the length of the list).
Any advice much appreciated!

Related

Excel graph with average column of increasing number of input data columns

I'm new to Excel so I don't know if it's even possible to do what I'm trying to.
I wanna build a graph with 3 columns of direct data and the last one should be an average of older data and every week I should add a new column with a newest one and that should update the graph becoming the first column, sending the previous one to the second one and so on until the previous 3rd one becomes part of the average column. I'm uploading some images to make things clearer.
Sorry about the paint images =/
If not clear, the average should be the mean values of all older columns and my graph should have always 4 columns no matter the amount of older ones.
I am open to other implementation methods that could give me a similar solution.

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

Distribution of time values randomly in a table Excel - Modeling Power Grid

I am working on a model of charging load of electric vehicle. I am attaching a link to an excel workbook for your better understanding.
Column B contains random time values
Column G to P represents houses and each house can have 1 car. So the each time values needs to be distributed in one column. Now when a car is plugged in, its load stays constant for 3 cells.
I want excel to randomly distribute these cars e.g. 4 cars to 4 houses and leave others blank.
what i can think of is, to assign each time a random house then use IF formula with AND function to match random times with time series and second condition to match random houses with columns 1-10.
the problem i am facing is, the formula gives a value error and only works in the rows with has random generated time in front of them screenshot. I know there is a very small thing that i am missing. please help me find it
Regards
workbook
=IF(ISNA(MATCH(G$5,$C$6:$C$9,FALSE)),"",IF(AND(INDEX($B$6:$B$9,MATCH(G$5,$C$6:$C$9,FALSE))>=$F6,INDEX($B$6:$B$9,MATCH(G$5,$C$6:$C$9,FALSE))<=$F6+TIME(0,30,0)),11,""))
The two elements in the AND find the house number in column C and return the corresponding time in column B.
The first element compares the time in F to that time. The second element compares the time + 30 minutes to F (three cells). If it's between those two times, it gets an 11.
The ISNA makes sure that the house in question is on the list. You could also use an IFERROR, but I prefer the precision of ISNA.
Update
If you want the values to wrap around, you need to OR compare to the next day.
=IF(ISNA(MATCH(G$5,$C$6:$C$9,FALSE)),"",IF(OR(AND(ROUND($F6,5)>=ROUND(INDEX($B$6:$B$9,MATCH(G$5,$C$6:$C$9,FALSE)),5),ROUND($F6,5)<=ROUND(INDEX($B$6:$B$9,MATCH(G$5,$C$6:$C$9,FALSE))+TIME(0,30,0),5)),AND(ROUND($F6+1,5)>=ROUND(INDEX($B$6:$B$9,MATCH(G$5,$C$6:$C$9,FALSE)),5),ROUND($F6+1,5)<=ROUND(INDEX($B$6:$B$9,MATCH(G$5,$C$6:$C$9,FALSE))+TIME(0,30,0),5))),11,""))
That formula structure looks like
=If(isna(),"",if(or(and(today,today),and(tomorrow,tomorrow)),11,"")
This formulas already getting too big. If you triple it for your three voltages, it will be huge. You should consider writing a UDF in VBA. It won't be as quick to calculate, but will probably be more maintainable.
If you want to stick with a formula, you could put the wattage in row 4 above the house number. Then in another table, list the wattages and minutes to charge. So in, say, B12:C14 you have
3.7 120
11 30
22 15
Now where you have 11 in your formula, you'd have G$4 and the two placed you have TIME(0,30,0), you'd have TIME(0,INDEX($C$12:$C$14,MATCH(G$4,$B$12:$B$14,FALSE)),0). I re-arranged some stuff to make it more 'readable' (but it's still pretty tough) and here's the final formula
=IF(ISNA(MATCH(G$5,$C$6:$C$9,FALSE)),"",IF(OR(AND(ROUND($F6,5)>=ROUND(INDEX($B$6:$B$9,MATCH(G$5,$C$6:$C$9,FALSE)),5),ROUND($F6,5)<=ROUND(INDEX($B$6:$B$9,MATCH(G$5,$C$6:$C$9,FALSE))+TIME(0,INDEX($C$12:$C$14,MATCH(G$4,$B$12:$B$14,FALSE)),0),5)),AND(ROUND($F6+1,5)>=ROUND(INDEX($B$6:$B$9,MATCH(G$5,$C$6:$C$9,FALSE)),5),ROUND($F6+1,5)<=ROUND(INDEX($B$6:$B$9,MATCH(G$5,$C$6:$C$9,FALSE))+TIME(0,INDEX($C$12:$C$14,MATCH(G$4,$B$12:$B$14,FALSE)),0),5))),G$4,""))

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)

Control which rows a data table will calculate

I have a 2-way data table in Excel (as in the option under "What-If Analysis"). There are 50 rows when analysing a 50 year deal, but only 4 rows when analysing a 4 year deal.
I only want to use one data table (of 50 rows) but I don't want it to calculate all of the values if it doesn't have to. e.g. if I have a five year deal I want the values in the first 5 rows to be calculated, but for the rest I would like it to display 0 or a blank.
Is there a way to do this without VBA?
(I was thinking with VBA I could create a whole new data table every time I run it, but would prefer not to as I am still developing structures.)
I'm guessing that either your row labels will step consistently. Just blank out the years that are not required, when not required (rows 6 and upwards in your example for 5 years), and repopulate with series fill to suit.

Resources