Excel formula using countif on sample data - excel

We want to find out how many Data00_A_Up and Data00_B_Up is there , we are not concerned about the digit which comes after A and B like A1,A2,B1,B2 and all. For all Data, that is Data00,Data01,...so on we need to find out how many Data_A_Up and Data_B_Up is there using formula in excel. I came up with this formula
=COUNTIF(A1:C10,"Data00_A?_Up")
this will give total A_Up for Data00. Similarly
=COUNTIF(A1:C10,"Data01_B?_Up")
this will give total number of B_Up for Data01.
Each time we have to edit this formula to Data01,Data02,etc. So is there any one formula to calculate everything at once.
Dataset

With Microsoft 365 you may try below formula to count Up for Data00, Data01...
=LET(x,UNIQUE(LEFT(A1:A10,SEARCH("_",A1:A10)-1)),CHOOSE({1,2},x,COUNTIFS(A1:A10,x&"*",A1:A10,"*Up")))
If you need to distinguish A and B then could try-
=LET(x,UNIQUE(LEFT(A1:A10,8)),CHOOSE({1,2},x,COUNTIFS(A1:A10,x&"*",A1:A10,"*Up")))

Related

Use VLOOKUP as criteria inside COUNTIFS

After years of using this community, I have a question that I can't find an answer to. I hope you all can help!
I am trying to get a count of the number of "Grounded" items that each individual is overdue for. My screenshot (Count Tracker) shows a very condensed version of what I'm working with. Columns A-C is my large (15,000 rows) data field that is imported from an external source. In columns G-H I have listed each possible task (about 100 rows) and the type (Grounded and Non-Grounding plus many others). Column F is where I am trying to get the count.
My formula in F9 currently uses COUNTIFS to get a count of the instances in the large array that equal E9 ("Smith" in this case) and where the due date in the large array is less than or equal to the current date in F8. What I can't figure out is how to also add to count the Tasks in the large array where the task type in Column H equals "Grounded". I tried VLOOKUP, but it seems it doesn't like it and tells me there is a problem with the formula. It doesn't work, but here's the general idea of what I'm after:
=COUNTIFS($A$2:$A$7,$E9,$C$2:$C$7,"<="&$F$8,VLOOKUP($B$2:$B$7,$G$2:$H$4,2,FALSE),"=Grounded")
With how the data is currently presented, Smith should have a count of 1 and Jones should have a count of 0. I have a feeling that this is more simple than I'm making it to be, but I can't figure it out. I am using Excel 2016.
Hopefully I explained the problem well enough. Thank you for your assistance.
With Excel 2016 I'd say MMULT() is a good alternative here:
CSE-Formula in F9:
=SUM((A$2:A$7=E9)*(MMULT((TRANSPOSE(G$2:G$4)=B$2:B$7)*(TRANSPOSE(H$2:H$4)="Grounding"),ROW(G$2:G$4)^0))*(C$2:C$7<=F$8))
You could add a fourth column that stores whether that Task is Grounded
The formula for D2 would then be:
=INDEX($H$2:$H$4,MATCH(B2,$G$2:$G$4,0))
Modify your CountIfs formula to use this new column as a criteria
=COUNTIFS($A$2:$A$7,$E9,$C$2:$C$7,"<="&$F$8,$D$2:$D$7, "Grounded")
Try this Sumproduct+Vlookup formula without helper solution, and can work for your Excel 2016
In F9, formula copied down :
=SUMPRODUCT((A$2:A$7=E9)*(VLOOKUP(T(IF({1},$B$2:$B$7)),G$2:H$4,2,0)="Grounded")*($C$2:$C$7<=$F$8))

(EXCEL) How to make a final column that counts the number of numbers that is larger compared to the other row in excel?

I want to make a table that, in its final column, counts the number of numbers such that the row is larger than the other row. However, since the sample size for me is rather large, I want an excel formula to do this for me.
I have tried using sum, if, sumif, sumifs commands, but none seems to work (at least I can't get it to work). Any help would be appreciated.
Here is a small sample:
You can do =SUM(--(row_2_range>row_1_range)).
For example:
EDIT: to account for blanks and non-numeric data, you can use something like
=SUM(--(IF(ISNUMBER(G3:I3),G3:I3,0)>IF(ISNUMBER(G2:I2), G2:I2,0)))
You may try SUMPRODUCT()
=SUMPRODUCT(--(A1:F1>A2:F2))
In G2 cell =SUMPRODUCT(--(A2:F2>A1:F1)).

SUMPRODUCT with Dates for Criteria

I am trying to obtain an average of an array of fields with the following simple formula
=SUMPRODUCT(Main!BA:BA, Main!CY:CY, --(Main!D:D >=D3, Main!D:D <=E3))
I'm getting a #DIV/0! error. I have no clue why it's dividing anything. Please help!
Basically, how can I get the sum product of columns D vs E between the dates 11/05 to 11/27.
You need to use * or + depending on whether you want AND or OR.
=SUMPRODUCT(Main!BA:BA, Main!CY:CY, (Main!D:D >=D3)*(Main!D:D <=E3))
One more note:
You want to limit the references to only that with data as this formula will do a lot of unneeded calculations.
From looking at your worksheet, you want this:
=SUMPRODUCT(D:D*E:E*(C:C>=$C$27)*(C:C<=$C$49))

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.

CountIF error with <0

I would need some help again with another excel countif expression. I have the line i2:al2 which contains leftover stock data.I am building a worksheet to calculate remaining stocks in % as per supervisor's wish.
As I am working with %, for example if I say that 90% sales that means we have 103 stock left and with 91% sales I have 100 stock left.
Anyways I got around to count the number of stock left in line i2:a12 using countifs.
Example if I need to calculate leftover stock for sales at 90% which means leftover stock level of 100 to 102. I have used :
=countif(range,">100")-countif(range,">102")
This method seems to work till I reach negative numbers, i.e. oversales. For example, if I try to do the following:
=countif(range,"-100")-countif(range,">0")
the formula seems to stop working. If I count manually using a conditional formatting I get a totally different answer for the oversales.
Maybe I am getting the logic of the countif function wrong. My purpose for the expressison is:
=count(in range, values >=X & <=Y)
As I have only access to excel 2003 I cannot use Countifs method. Anyone could help me on this issue?
Many thanks.
You can use an array formula:
=SUM((range>=x)*(range<=y))
For that to work, you need to press CTRL-SHIFT-ENTER for that to use array formula.
Alternatively, using what simoco gives in the comment works too without having to save as array formula.

Resources