Range filtering on excel and count rows - excel

I need your help about an excel range filtering, it's about a school project.
I have an excel file with 20k rows and a column with number range from 0 to 350k and I need somehow to filter them every 1k (0-999,1000-1999 etc) and to count how many rows/records have every team.
I am thinking about macros or VBA script but i don't even know the starting point, i hope someone can help me from where to start.
Many thanks!

With Office 365 we can do this in one formula and the results will spill:
=CHOOSE({1,2,3},SEQUENCE(351,,0,1000),SEQUENCE(351,,999,1000),FREQUENCY(A:A,SEQUENCE(350,,999,1000)))
Frequency is designed to take the number and the array of buckets and return the count.
With LET we can move the variables to the front:
=LET(
rng, A:A,
nmbckts, 351,
gp, 1000,
CHOOSE({1,2,3},
SEQUENCE(nmbckts,,0,gp),
SEQUENCE(nmbckts,,gp-1,gp),
FREQUENCY(rng,SEQUENCE(nmbckts-1,,gp-1,gp))))

No VBA needed:
If your values are in column A, just enter 0 and 9999 like in columns D/E. The rest of the numbers can be done with =D2+1000 and =E2+1000 and pulled down until 350k.
The counting can be done with =COUNTIFS(A:A,">="&D:D,A:A,"<="&E:E) in column F and pulled down.

Related

How to identify and name different ranges in one column in Excel?

I have a recorded drive cycle of a truck which includes speed and coordinates over time. The file looks like this (simplified version)
I want to know the number of times the truck is stopped (when speed = 0) and number them. Therefore, I would like to group the intervals with '0' values (vehicle stopped) in the Speed column and name them in order (Stop 1, Stop 2, etc). Ultimately, my goal would be to somehow be able to calculate the number of stops and duration like this:
Is there any function in Excel which would allow me to do something like that? Thank you.
You can do it using Pivot Tables and a helper column. Also if you have Excel365 with functions like FILTER,UNIQUE and SUMIFS
Formula helper column is just to enumerate properly each group of stops. Notice data need to be sorted properly as your exampel or it won't work:
=IF(D2="STOP";IF(D1="STOP";E1;MAX($E$1:E1)+1);"")
Then pivot table can be inserted:
Helper Column and Vehicle Stop into rows section
Time-step seconds into values section, formated as Time and operation=Sum
Filter field Helper Column to exclude blanks
If you have Excel 365, you can get this output with advanced formulas. In cell J14 formula is:
=UNIQUE(FILTER(D2:D19&E2:E19;D2:D19="STOP"))
And K14 is (and drag down) is:
=SUMIFS($B$2:$B$19;$D$2:$D$19;"STOP";$E$2:$E$19;MID(J14;5;99))
Anyways, I've uploaded the workbook to Gdrive so you can see the Pivot Table and the formulas by yourself. If you don't jave Excel 365, the formulation part may give some errors when you open it:
https://docs.google.com/spreadsheets/d/1t1INxGKJRHFexWnSC5LlIi37JrThjajs/edit?usp=sharing&ouid=114417674018837700466&rtpof=true&sd=true
Just as a postscript to this, you could do the same thing without using helper columns by comparing offset ranges to see where the transitions in speed occurred from 0 to 10 (go) or 10 to 0 (stop). The problem is that normally you would have to go outside the data range (a2:a16 and c2:c16) which gets you either a header cell (a1 or c1) or a blank cell (a17 or c17). In the case of time, there is also a special case where the first time-step is taken to be zero.
All this can be avoided in Excel 365 by using vstack to add appropriate dummy values to the beginning or end of the two ranges:
=LET(timeRange,A2:A16,
speedRange,C2:C16,
timeRange1,VSTACK(A2,timeRange),
speedRange1,VSTACK(1,speedRange),
speedRange2,VSTACK(speedRange,1),
startTime,FILTER(timeRange1,(speedRange1>0)*(speedRange2=0)),
endTime,FILTER(timeRange1,(speedRange1=0)*(speedRange2>0)),
stopTime,endTime-startTime,
label,"STOP "&SEQUENCE(ROWS(stopTime)),
HSTACK(label,stopTime))

How to sum the output of multiple DATEDIF results in Excel

So, I’ve created an Excel sheet for work that sums the total between two dates (on multiple different lines) with each individual lines result being in the D, M , Y format. No problem there.
Here’s a screen shot of my Excel sheet thus far.
The formula I’m using is =DATEDIF(A2,C2, “y”) &” years, “&DATEDIF(A2,C2, “ym”) &” months, “ &DATEDIF(A2,C2, “md”) &” days”
But now I need a formula to sum the results of all the lines into one aggregate total of them all. Here’s the curveball - this sheet will be used as a calculator and the list of dates will change between each use.
Any help is greatly appreciated!
Thank you!
It would probably be easiest to make three columns: one for =DATEDIF(A2,B2,"Y"), one for =DATEDIF(A2,B2,"YM"), and one for =DATEDIF(A2,B2,"MD"),
Then you can have a function in either a different column with Sum(C:C) or in the top row of that column with Sum(C2:C50) (this is assuming that you will have max 50 rows. you can set it to the bottom possible row if you want).
Here is how I did it (The sum function is a little different because I used google sheets):

Excel Formula to Count Values between Dates

I am looking for a way to count how many companies are in Column C on the specific dates of column A. Can one formula be applied to the count between all of dates?
I have tried looking up and using =CountBlanks and I do not want to have to manually select the cell ranges between the dates.
Ultimately I am also trying to put this data into a table so I can see on Feb 16 = 3 Companies, Feb 19 = 5. I can not use a VBA script as some users have macros blocked.
Please look at image for example
Example Image
Try this formula:
=COUNTA(INDEX($C$2:$C$21,MATCH($E2,$A$2:$A$21,0)):INDEX($C$2:$C$21,MIN(IFERROR(MATCH(TRUE,INDEX($A$2:$A$21>$E2,0),0),9999999),MATCH(TRUE,INDEX($C$2:$C$21="",0),0))-1))
Change the 21s in the formula to at least the extent of your data +1, It can be more, Full column references will not work due to the Word "Date" in the first row.
DATEDIF( start_date, end_date, interval )
you didnt even bother to google this, right?
edit: there should be enough common place stuff like isblank to accommodate the lack of values. If youre trying to find the values between A & C then you can easily adjust your formula accordingly.

Excel Counting non blank cells

I am having no luck trying to count my non blank cells in excel. I have tried multiple formulas and I keep getting inaccurate data. Here is the situation:
I am creating a Preventative Care list for my physicians (I have 4) I created a list of all their patients that have received a letter re: Prev. Care and I am inputting who needs a second letter and who has results. Some results are negative, some are positive. I have the list set up in alphabetical order on patients last name and then I have their physician initials in the other column. I want to check to see what percentage of each doctors patients have done their prev. care. I want to calculate this separately. Unfortunately, the cells are no in order. I have tried everything to my knowledge.
Help!
This will give you how many blank cells you have. You can deduct this from the total number of cells in your column, or you could use this directly to compute your percentage as (1 - x) where x is percentage of blank cells.
=COUNTBLANK(<your column>)
E.g:
=COUNTBLANK(A1:A10)
If it's not immediately obvious how to count the total number of cells in a range, this formula should help explain, answering the original question fully. It works with ranges that span more than 1 column, too.
=ROWS(range)*COLUMNS(range)-COUNTBLANK(range)
You might try something like:
=IF(LEN(A1) > 0, 1, 0)
You can then sum that column or do whatever other calculation you need.
=COUNTIF(range,"<>"&"") will count all cells that do not have a value equivalent to "", so, basically anything that is not blank.

Altering a COUNT to a COUNTIF to count 100 values across a number of sheets

I've inherited a spreadsheet at work and I want to edit it to suit my needs. It currently uses the following formula to count row values across various sheets (including 0 values).
=IF(ISERROR(COUNT(INDIRECT($A5&"F"&MATCH(D$1,INDIRECT($A5&"B1:B13"),0)&":IV"&MATCH(D$1,INDIRECT($A5&"B1:B13"),0)))),"",COUNT(INDIRECT($A5&"F"&MATCH(D$1,INDIRECT($A5&"B1:B13"),0)&":IV"&MATCH(D$1,INDIRECT($A5&"B1:B13"),0))))
Now, I'd like to amend this formula so that it only counts values that are =100. I assume this would mean using the COUNTIF function but I can't quite work it out as it is quite a complicated formula for me. Hopefully this is an easy fix for someone who knows what they are doing.
It is for test scores. Say in the row someone has 100, 90, 100, 90, 100. It is currently bringing back the result of 5. I'd like to alter this so it brings back a result of 3 as there were three 100 scores. Obviously it is a little more complicated because it is working across a range of sheets (1 person = 1 sheet) and it is bringing back results for as many as 20 people on some of these workbooks.
Thanks in advance. Really appreciate it!
If you have Excel 2007 or later then you can use this formula to count 100s in the relevant range - using IFERROR for error checking purposes, i.e.
=IFERROR(COUNTIF(INDEX(INDIRECT($A5&"F1:IV13"),MATCH(D$1,INDIRECT($A5&"B1:B13"),0),0),100),0)
or in earlier versions of Excel try
=LOOKUP(9.9E+307,IF({1,0},0,COUNTIF(INDEX(INDIRECT($A5&"F1:IV13"),MATCH(D$1,INDIRECT($A5&"B1:B13"),0),0),100)))

Resources