COUNTIFS when counting distinct values - excel

I've got a table that looks something like this
what I want to do is have a formula that counts how many distinct machines are used on each hospital in between 04/06/2021 and 07/06/2021
So I would get something like this
I feel like this could be done with a COUNTIFS but somehow make it count only distinct values. I'm just not sure of how I could do this. Can someone help me with this? Thanks

To expand on the comments, if you have the newest version of Excel you can use functions like FILTER, COUNTA, and UNIQUE.
For example, after getting the unique hospitals with UNIQUE, try something like:
=COUNTA(UNIQUE(
FILTER($B$2:$B$10,
(($C$2:$C$10<DATEVALUE("1/5/2021"))*
($C$2:$C$10>=DATEVALUE("1/1/2021"))*
($A$2:$A$10=$F2)))))

Related

How can I do a work order drawdown in excel?

I know drawdown isn't the correct word, but I also don't know the correct word to use so if you know it tell me as well please.
What I'm trying to do is for a list of open work orders, apply an incoming PO to fill that work order, and then when the quantity in that first PO is exhausted roll to the next PO. I have tables that look similar to these, although the order of the columns can change if need be. Typically the order of the work orders are sorted in date order, as well as PO. Double points if this can be achieved without using VBA, and could just be a formula. Helper columns and tables are also fine. thanks!
then my PO's are something like this
and I would like the result to look something like this (although the remaining column isn't necessary, it would be helpful)

Can I use MINIFS or INDEX/MATCH on two non-contiguous ranges...?

Problem is straightforward, but solution is escaping. Hopefully some master here can provide insight.
I have a big data grid with prices. Those prices are ordered by location (rows) and business name (cols). I need to match the location/row by looking at two criteria (location name and a second column). Once the matching row is found (there will always be a match), I need to get the minimum/lowest price from two ranges within the grid.
The last point is the real challenge. Unlike a normal INDEX or MINIFS scenario, the columns I need to MIN aren't contiguous... for example, I need to know what the MIN value is between I4:J1331 and Q4:U1331. It's not an intersection, it's a contiguous set of values across two different arrays.
You're probably saying "hey, why don't you just reorder your table to make them contiguous"... not an option. I have a lot of data, and this spreadsheet is used for a bunch of other stuff. So, I have to work with the format I have, and that means figuring out how to do a lookup/min across multiple non-contiguous ranges. My latest attempt:
=MINIFS(AND($I$4:$J$1331,$K$4:$P$1331),$B$4:$B$1331,$A2,$E$4:$E$1331,$B2)
Didn't work, but it should make it more clear what I'm trying to do. There has GOT to be an easy way to just tell excel "use these two ranges instead of one".
Thanks,
Rick
Figured it out. For anyone else who's interested, there doesn't seem to be any easy way to just "AND" arrays together for a search (Hello MS, backlog please). So, what I did instead was to just create multiple INDEX/MATCH arrays inside of a MIN function and take the result. Like this:
MIN((INDEX/MATCH ARRAY 1),(INDEX/MATCH ARRAY 2))
They both have identical criteria, the only difference is the set of arrays being indexed in each function. That basically gives me this:
MIN((match array),(match array))
And Min can then pull the lowest value from either.
Not as elegant as I'd like... lots of redundant code, but at least it works.
-rt

Ranking and then displaying results

I'm trying to display the name from top to bottom based on a ranking. Can't seem to find a way to pull the info I need. I looked into VLOOKUP but the order of the cells don't work for me.
Pretty simple, I have rep, number of calls, ranked based on most calls and I want to display the names in the order of ranking. I want it to look like this
Want it to look like this:
I know its a simple solution but I am stuck.
Thinking ahead, how would I deal with same results when RANK.EQ give me 2 people on 4th position for example.
Thank you!
In V2:W2,
=SMALL(T$2:T$8, ROW(1:1))
=INDEX(Q:Q, AGGREGATE(15, 6, ROW($2:$8)/(T$2:T$8=V2), COUNTIF(V$2:V2, V2)))
Fill down.

Find only two decimals

I am very new to Excel, a beginner! I need a formula/macro to find 1-2 decimals in a column. The column contains job codes for all levels of the organization. It would look something like this:
xx.xxx
xx.xxx.xxx
xx.xxx.xxx.xxx
xx.xxx.xxx
xx.xxx.xxx.xxx
xx.xxx.xxx.xxx.xxx
xx.xxx.xxx.xxx.xxx.xxx
xx.xxx.xxx.xxx.xxx.xxx.xxx
I need to find only the job codes with one or two decimals, which specify a certain position in the organization, the end result looking like this:
xx.xxx
xx.xxx.xxx
xx.xxx.xxx
Does anyone have any ideas on how to do this? Thank you in advance!
You could use a helper column to count the occurrence of . and then just filter this column:
=LEN(A1)-LEN(SUBSTITUTE(A1,".",""))
To Do it without a helper column:
=IFERROR(INDEX($A$2:$A$9,AGGREGATE(15,6,(ROW($A$2:$A$9)-ROW($A$2)+1)/(LEN($A$2:$A$9)-LEN(SUBSTITUTE($A$2:$A$9,".",""))<=2),ROW(1:1))),"")

Month, Year and Countif

I am trying to develop a query which should pick out and count the data from a data pool corresponding to the year/month in the given (A106) cell.
While such (array) construct works:
COUNTIF(IF(MONTH(INDEX(Data.$A$1463:$A$1827))=MONTH(A106);Data.$B$1463:$B$1827);">0");
such one - does not:
COUNTIF(IF( MONTH(INDEX(Data.$A$1463:$A$1827))=MONTH(A106) and YEAR(INDEX(Data.$A$1463:$A$1827))=YEAR(A106));Data.$B$1463:$B$1827);">0")
It there anything to be done about it or it is impossible?
I believe that you might want to use a sumproduct for this (though there are certainly other ways to achieve the same result). This might do the trick:
SUMPRODUCT((MONTH(INDEX(Data.$A$1463:$A$1827))=MONTH($A$106))*(YEAR(INDEX(Data.$A$1463:$A$1827))=YEAR($A$106)))

Resources