Count year occurred from datetime - excel

I have data as below:
amos 50 10/16/2012 10:13
amri 50 1/9/2013 9:31
andi 10 3/11/2008 10:35
andik 10 12/6/2012 16:58
anggoro 50 9/13/2012 16:14
ari_prabowo 50 11/26/2012 10:30
astra_permana 10 8/2/2010 17:40
atang 10 1/16/2009 14:39
I want to counting how many times such like year of "2008", "2009", "2010", "2012", "2013" occurred.

Thanks for re-formatting your data.
I would add a helper column to calculate the year
=YEAR($A$1)
Then you can use a countif on that column
=COUNTIF($B$1:$B$10,2008)
Otherwise you could use a sumproduct (Excel 2003)
=SUMPRODUCT(($A$1:$A$10>=DATE(2008,1,1))*($A$1:$A$10<DATE(2009,1,1)))
Or countifs (excel 2007 +)
=COUNTIFS($A$1:$A$10,">=1/1/08",$A$1:$A$10,"<1/1/09")

Related

Excel not recognising all dates in same column

I paste the following in excel, half of them are not recognized as date in excel.
Have already tried text to columns, adding 0 to them. I think exhausted all online techniques.
My target is to convert them all this to this format yyyy-mm-dd hh:mm:ss
9/25/19 19:17
12/5/19 14:28
11/4/19 16:46
3/20/19 14:12
1/2/20 21:15
3/20/19 19:24
3/14/19 20:03
12/29/19 20:24
3/18/19 10:20
3/9/19 11:03
12/16/19 16:01
12/21/19 19:31
12/17/19 11:41
10/12/19 17:09
3/25/19 14:01
11/20/19 21:02
8/28/19 19:00
3/14/19 20:00
3/29/19 1:39
8/30/19 22:04
3/10/19 20:02
11/20/19 8:37
9/15/19 19:19
3/20/19 17:12
8/26/19 11:03
8/30/19 22:16
7/31/19 14:53
3/25/19 20:14
1/26/20 10:24
3/29/19 1:12
6/27/19 10:06
10/15/19 14:05
12/28/19 10:58
10/23/19 13:58
8/25/19 16:07
3/27/19 16:28
3/23/19 11:26
3/24/19 11:13
3/18/19 10:11
3/25/19 13:39
3/26/19 16:35
3/27/19 21:11
11/27/19 13:23
The data sample uses the MDY order. If Excel doesn't recognize half of these as dates, your regional settings use the DMY order.
Instead of pasting the data into Excel, put it into a text file and then open the text file with Excel. That will launch the Text Import Wizard.
Keep Delimited selected and click Next
In Step 2, click Space and click Next. Date and time will now be split into two columns.
In Step 3 of 3, select the first column and click the Date radio button and set the drop-down to MDY.
Click Finish and the data will be in your worksheet as dates.
You can now use formulas to bring the time and date back together by adding the cells, =A1+B1 - and then use formatting to display the date/time values any way you want.

Excel: How to change the date column to display only Month of the date?

I'm working on generating a report by month and I'm going to create Graph based on the month values.
Consider I'm having 1000+ records in my excel sheet and there is a column called created_date which is containing the values like 11/1/2019 1:34:00 AM. I'm looking for a function or any solution to convert the created_date value to 11 or 11/2019 so I can generate a chart by Month.
Note: I'm using the online version of Microsoft Excel for this operation.
For Example - I have attached some records below.
Created_date
11/1/2019 1:34
11/1/2019 0:10
10/31/2019 19:31
10/31/2019 8:32
10/31/2019 3:59
10/31/2019 0:06
10/29/2019 23:48
10/29/2019 23:37
10/29/2019 22:35
10/29/2019 22:33
10/29/2019 22:26
10/29/2019 19:15
10/25/2019 20:44
10/25/2019 3:36
10/5/2019 3:25
10/5/2019 1:52
10/3/2019 0:40
10/2/2019 19:23
10/1/2019 3:56
9/27/2019 4:23
9/27/2019 0:19
9/25/2019 0:46
9/24/2019 22:22
9/24/2019 22:20
9/24/2019 17:12
9/20/2019 20:21
Assume your data is in cell A1, input the formula into cell B1 =TEXT(A1,"mm/yyyy"). This wil give you output of 11/2019. If you only want a 2 digit month, change the formula to =TEXT(A1,"mm"). You can then reference your chart to this new column.

Aging Bucket DAX formula issue

I have a table as stated below,
MEM_ID dateDiff
4522 10
111 1
1112 -1
1232 5
121135 20
145 30
12254 60
I want a Dax formula which will give the output as stated below under measure column as
MEM_ID dateDiff Measure
4522 10 0-15 Days
111 1 0-15 Days
1112 -1 <0 Days
1232 5 0-15 Days
121135 20 15-30 Days
145 30 15-30 Days
12254 60 >60 Days
I have used this formula which didnt worked, any help much appriricated =IF(MAX([DateDiff]) <= 1, "0", IF(MAX([DateDiff])>=1 && MAX([DateDiff])<15,"1-15 Days",IF(MAX([DateDiff])>=15 && MAX([DateDiff])<30,"15-30 Days",IF(MAX([DateDiff])>=30 && MAX([DateDiff])<60,"30-60 Days",IF(MAX([DateDiff])>=60 && MAX([DateDiff])<90,"60-90",BLANK())))))
Using a lookup-table like Ian Ash suggests is better, but if you must use an IF formula, Try the formula you have, but delete the MAX functions.
=IF([DateDiff]< 1, "0",
IF([DateDiff]>=1 && [DateDiff]<15,"1- 15 days",
IF([DateDiff]>=15 && [DateDiff]<30,"15-30 Days",
IF([DateDiff]>=30 && [DateDiff]<60,"30-60 Days",
IF([DateDiff]>=60 && [DateDiff]<90,"60-90",
BLANK())))))
I would solve this problem by creating a look up table as follows.
Create a new worksheet called Lookup, then starting from A1 add the following data:
Min Max Bucket Description
-1000 0 1 <0 Days
1 15 2 0 - 15 Days
16 30 3 16 - 30 Days
You can add additional rows if you need to add more buckets. For example, to create a bucket for 30 to 60, you would add the row:
31 60 4 30 - 60 Days
Once you have the lookup table defined, you can reference into it using the following formula from your main worksheet:
=OFFSET(Lookup!$A$1,SUMPRODUCT((B2>=Lookup!$A$2:$A$4)*(B2<=Lookup!$B$2:$B$4)*(Lookup!$C$2:$C$4)),3)
In the above formula, the value being looked up is in B2.
If you have added rows to your lookup table, you will need to extend the look up range in the formula, i.e. Lookup!$A$2:$A$4 changes to Lookup!$A$2:$A$5 and so on.

how to value hh:mm in Ms Excel correctly so that certain values can be assigned to it

Please could anyone kindly help. Thanking you in advance. My problem is as the following:
I have thousands lines of data with two clusters of time. One is in sheet1, for example, random times from 16pm to 20pm or 4 hours or 240 minutes, I would like to give value to them i.e. 1 to 241
(column B)
A B
17:19
17:19
17:19
18:06
18:06
18:06
16:30
16:30
16:30
I have a second sheet which will give values to sheet1 column B, the content of sheet2 is:
16:00 1
16:01 2
16:02 3
.
.
.
17:19 80
17:20 81
17:21 82
.
.
.
18:06 127
18:07 128
18:08 129
.
.
.
16:30 31
16:31 32
16:32 33
.
.
.
19:58 239
19:59 240
20:00 241
I tried to use VLOOKUP, hour, minute to get values for sheet1 B, using sheet2 but I am still unsuccessful (I kept getting false value from comparing two columns containing times) e.g. in sheet1 column B, say B2 I have
=IFERROR(VLOOKUP($B2,'sheet2'!$A:$B,2,FALSE),"")
My solution did not work. if possible I should get sheet1 filled in like
A B
17:19 80
17:19 80
17:19 80
18:06 127
18:06 127
18:06 127
16:30 31
16:30 31
16:30 31
You can use an excel formula like this:
B2: =(HOUR(A2)*60)+MINUTE(A2)+1
This is just calculating the number of minutes after midnight. If you wanted to start at say, 16:00, you would just modify it like this:
Set a value somewhere that is the START time... In this example I have "$E$4" set to 16:00
=(HOUR(A3-$E$4)*60)+MINUTE(A3)+1
You could put your start time on another sheet or anywhere.
Of course you can always add the If statement to deal with empty rows:
=IF(A2="","",(HOUR(A3-$E$4)*60)+MINUTE(A3)+1)
In the example, note in the screenshot in column A, the formatting is TIME for row 2, and General for rows 3 & 4. The formula will work for either.
edit:added IF statement & description of screenshot.
EDIT AFTER COMMENT: Modified formula to add 1 minute.
I finally, found a correct answer
=(HOUR(A2)-16)*60+MINUTE(A2)+1
so 16:00 will give 1, 16:30 will give 31, 17:19 will give 80 and so on, 20:00 will give 241.
Thanks for trying to help, PJ Rosenburg. Indeed I was on right track in using hour and minute, BUT I do not even need to use VLOOKUP.

Daily and Hourly Averages from (m/d/yyyy h:mm) timestamps in Excel

I have an Excel 2007 spreadsheet with date entries in this format m/d/yyyy h:mm (one cell). I would like find the hourly and daily average of all the columns of this spreadsheet and save each time aggregation to a new worksheet.
The data is recorded every ~10 minutes, but throughout the dates of data collection there was some time slips. Not every hour has the same number of rows. Also, the ending minute is either 0 or 6 depending on the time correction.
What would be a good way to approach this task within Excel 2007? It seems like this might be possible with a pivot table if I can create a formula that will select the correct range for the timestamps. Thanks.
For example, an date time entry in TIMESTAMP, 10/31/2012 0:06 which is in one cell.
TIMESTAMP Month Day Year Hour Min Rain_mm Rain_mm_2 AirTC AirTC_2 FuelM FuelM_2 VW ... there are ~16 variables (total) after the data time
10/31/2012 0:06 10 31 2012 0 06 0 0 26.11 26.08 2.545 6.4 0.049
10/31/2012 0:16 10 31 2012 0 16 0 0 25.98 25.97 2.624 6.6 0.049
10/31/2012 0:26 10 31 2012 0 26 0 0 24.32 23.33 2.543 6.5 0.048
10/31/2012 0:36 10 31 2012 0 36 0 0 24.32 23.33 2.543 6.5 0.048
10/31/2012 0:46 10 31 2012 0 46 0 0 24.32 23.33 2.543 6.5 0.048
10/31/2012 0:56 10 31 2012 0 56 0 0 25.87 25.87 2.753 7.3 0.049
10/31/2012 1:06 10 31 2012 0 06 0 0 25.74 25.74 2.879 8.1 0.051
## The above is just over one hour of collection on one day ##
...
## Different Day ### Notice Missing Time Stamp
11/30/2012 0:00 11 30 2012 0 06 0 0.1 26.12 26.18 2.535 6.4 0.049
11/30/2012 0:10 11 30 2012 0 16 0 0.1 25.90 25.77 2.424 6.6 0.049
11/30/2012 0:20 11 30 2012 0 26 0.1 0.2 24.12 24.43 2.542 6.4 0.046
11/30/2012 0:30 11 30 2012 0 36 0.1 0 24.22 22.32 2.543 6.5 0.048
11/30/2012 0:50 11 30 2012 0 56 0.1 0.2 26.77 25.87 2.743 6.3 0.049
11/30/2012 1:00 11 30 2012 0 06 0 0 24.34 24.77 2.459 5.1 0.050
## so forth on so on ##
After clarification of the requirement for daily averages edited to cover both daily and hourly averages:
Add a column (here B) for ‘H’ (ie hour) with =HOUR(A2) copied down.
(Note: Though formatted to show only m/d/y content of ColumnA is, in line with title, assumed to be all of mm/dd/yyyy hh:mm. Makes existing columns [with names jumbled] Month, Day, Year, Hour redundant).
Select data range.
Data, Subtotal, At each change in: TIMESTAMP, Use function: Average, Add subtotal to: check only columns G and to the right, OK.
Uncheck Replace current subtotals in Subtotal and apply At each change in: H, Use function: Average, and Add subtotal to: as before, OK.
Replace =SUBTOTAL(1, in Min column with =MIN( .
Delete ‘spare’ Grand Average row.
Reformat as required.
Hopefully this will be achieved and is what is required!:
Note midnight 'tonight' is counted as within first hour of tomorrow.
I had a similar need and worked it out this way:
Add a column for Date (assuming your dd/mm/yyyy hh:mm:ss data is in cell A2)
=DATE(YEAR(A2),MONTH(A2),DAY(A2))
Add a column for Year. If you have weeks from a single year, the year column can be neglected.
=YEAR(A2)
Add a column for Week Number
=WEEKNUM(A2)
Add 2 pivot tables, 1 for daily and 1 for weekly analysis.
Choose fields "Date" and the quantities you want. Put "Date" in the Rows section and sum/average of values in the Values section. You will get a date wise sum/average of the values you need.
In the weekly pivot table, do the same as above, just add "Year" and "Week no" in the Rows section instead of "Dates" as in above.
Hope this helps

Resources