COUNTIF and IF to return value - excel

Example Data Picture:
Basically associates use two different systems to log calls and there is a scenario where the same call is logged on two different systems. It gives a unique ID for each call, so perceived two be two calls instead of one. I need to be able to match these up and present as one call.
Data being used and to look up.
Call ID
Unique Client ID
Date
The System is the field I need to return the value for - above is a dummy result I would ideally like.
As you can see from the picture for Client 'ABC' there have been two entries on same day with different Call IDs, so I would want to show different systems have been used, for the other entries they are 'purely' unique so show 1 system.
I have tried COUNTIFS with date logic but can't get anything to work or come close.
This is only one part to the formula as I would then need to go onto checking time of call validations as well but that's for another time.
What I really need - which would work better - would be if Client ID is duplicated on Same Day then show True - If not show false?

if Client ID is duplicated on Same Day then show True - If not show false
Please try in D2 and copied down to suit:
=COUNTIFS(C:C,C2,B:B,B2)>1

I can't see your picture, but from your description;
If you have Call ID Unique in Column A and Call ID Date in Column B, assuming your data is contained in rows 2 to 50, place this function in cell C2 and drag down, if the function finds any duplicates, the count will be increased from 1 to the number of duplicates found in the list:
=IF(AVERAGEIF($B$2:$B$50,B2,$A$2:$A$50)/COUNTIF($B$2:$B$50,B2)<>AVERAGEIF($B$2:$B$50,B2,$A$2:$A$50),COUNTIF($B$2:B2,B2),1)
Then you can just filter out anything that's not a 1
Edit If you want to change the outputs to True or False, just do the following instead:
=IF(AVERAGEIF($B$2:$B$50,B2,$A$2:$A$50)/COUNTIF($B$2:$B$50,B2)<>AVERAGEIF($B$2:$B$50,B2,$A$2:$A$50),TRUE,FALSE)
However, this will flag all occurrences of the calls as True, if you want just the duplicates to be flagged, it would be:
=IF(AVERAGEIF($B$2:$B$50,B2,$A$2:$A$50)/COUNTIF($B$2:$B$50,B2)<>AVERAGEIF($B$2:$B$50,B2,$A$2:$A$50),IF(COUNTIFS($B$2:B2,B2,$A$2:A2,A2)>1,TRUE,FALSE),FALSE)

Related

Auto populate a table based from datas from another table

this is the another version of my first question and I hope I can best explain my problem this time.
From the Table 1, I want to auto populate Table 2 based on this conditions and criteria (below)
From the example, I basically have 3 initial criteria, ON CALL, AVAILABLE, and BREAK
Now for the conditions, I want all Agents from status ON CALL, AVAILABLE, BREAK from Table 1 to be populated on Table 2 (optional: If possible, I wanted only to show agents that HAS a duration of 4 minutes and above from each status). My problem is I always refresh TABLE 1 so I can get an updated data. My goal here is to monitor our agents their current Status and Running Duration, and from that I only need to check on the table 2 so I would see right away who has the highest running duration from each status to be called out.
I only tried MAXIFS function but my problem with it, I can only show 1 result from each status.
What I wanted is to fully populate Table 2 from the data on Table 1. If this is possible with ROW function that would be great, because what I really wanted is a clean Table, and it should only load data if the criteria is met.
Thank you
Something you may be interested in doing is utilizing HSTACK. I am not sure how you are currently obtaining the Agents name in the adjacent column to the results but this would populate both the Agent along with the Duration.
=HSTACK(INDEX(A:C,MATCH(SORT(FILTER(C:C,(C:C>=TIMEVALUE("00:04:00"))*(B:B=H2),""),1,1),C:C,0),1),TEXT(SORT(FILTER(C:C,(C:C>=TIMEVALUE("00:04:00"))*(B:B=H2),""),1,1),"[h]:mm:ss"))
This formula checks Table 1 for any Agent with the status referenced in H2 (Available) that also has a time greater than or equal to 4 mins. It then sorts the results in ascending order and populates the Agent Name that is associated with it. It is dynamic and will produce a table like the following:
Just update the formula to check for "On Call" and "BreaK" as desired for the other two.
UPDATE:
As for conditional formatting, this is utilizing the custom formula posted in the comments. If the formatting of the times are of [h]:mm:ss then you would be looking to do something like this. Notice the 2 cells are highlighted for being between 4 mins and 5 mins.
This is an array solution that spill all the results at once. We use a user LAMBDA function GET to avoid repetition of the same calculation using as input parameter the status (s). The formula works for durations in time format or in text format with a minor modification. On cell E2 put the following formula for durations in time format:
=LET(GET, LAMBDA(s, FILTER(HSTACK(A:A, C:C), (B:B=s)
* IFERROR(C:C >= TIME(0,4,0), FALSE))),
IFERROR(HSTACK(GET("ON CALL"), GET("Available"), GET("Break")),""))
Here is the output:
For durations as text in hh:mm:ss format just replace: C:C >= TIME(0,4,0) with TIMEVALUE(C:C) >= TIME(0,4,0).
The GET function is reused to generate the result for each status. The last IFERROR call is used to remove #N/A values generated by HSTACK when the column doesn't have the maximum number of rows of the output.
The first IFERROR is used to treat the case when the value is not numeric, such has the header. This is because we are using the entire column as input range. Using entire columns produce more concise formulas with less maintenance effort, but it is less efficient, unless you have a good reason to have an open range. If you want to use a specific range instead for the data of the table, then you can remove it and update the ranges accordingly.

MAXIFS function that increments to return 2nd,3rd largest numbers

I have a column called Paid which consists of currency figures which is in column A.
I also have a column called ID to uniquely define each of the rows which is in column B.
I am trying to make a top ten list of the highest results from this column.
For the first result, I use a simple MAX function.
For the following, I use
=MAXIFS(Combined!$A$1:$A$2916,$A$1:$A$2916,"<"&$C1)
where C1 is the first result in the top 10 list.
THE ISSUE: Currently, if two results are equal in Paid, one will get skipped and not be on the list.
I've tried using something in the nature of
=MAXIFS($A$1:$A$2916,$B$2:$B$2916,"<>"&$D1)
where D1 is the ID of the 1st in the top 10 list.
My issue here is that I want to use a condition to say that none of the ID's in the B column appear in the above entries in the D column(IDs of the top 10) and I don't know how to do this without brute forcing and writing each cell into each condition.
Is there a smoother way to write a "not in" check in a maxif function?
Thanks
For reference, an example of what I want would look like:
Example Data
Maybe try:
Formula in C2:
=INDEX(SORT(A2:B11,1,-1),SEQUENCE(10),{1,2})
Where 10 is your top N figure.
Note: The above works fine in retrieving only 10 figures, yet if you insist you want top have ID '5' above '3' in rank 2, and ID '9' above '1' for rank 8, then use:
=INDEX(SORTBY(A2:B11,A2:A11,-1;B2:B11,-1),SEQUENCE(10),{1,2})
I could see this being relevant if you have two identical payments "battle" for e.g. 1st or 10th place with one of multiple id's comming short.

Sum all rows when at least one row meets the criteria

I have a database as follows:
I am having issues trying to sum all the quantities by groups when the “Included” flag is Y for at least one of the groups; that is: if there’s a Y on at least one row from group 3 , sum all the rows from group 3, regardless if the rest are not included.
The output should be like this:
Thanks!
You're going to need to use an array function to solve this one. To enter and array function, type a function as you normally would then press Ctrl+Shift+Enter instead just Enter. (Apple Keyboards differ, but I don't have Apple.)
I'll explain how I put the function together, then bring it all together in the end.
First, I wanted an array of group numbers that have at least one "Y" in the Included column. That array is created by IF(B2:B14="Y",A2:A14,0). The result would be {0,0,0,0,0,0,3,...etc} in the sample case.
Next, I flag every group row that has an entry in the list of group numbers using the MATCH(A2:A14,IF(B2:B14="Y",A2:A14,0),0) function.
Since that uses an exact match, it will create an error when there is no match. ISERROR(MATCH(A2:A14,IF(B2:B14="Y",A2:A14,0),0)) gives me a true when there is not a match and a false when there is, so I negate it. NOT(ISERROR(MATCH(A2:A14,IF(B2:B14="Y",A2:A14,0),0)))
Another IF converts this to a 1 or a 0.
IF(NOT(ISERROR(MATCH(A2:A14,IF(B2:B14="Y",A2:A14,0),0))),1,0)
Finally, I bring it together with the Quantity using a SUMPRODUCT:
=SUMPRODUCT(C2:C14,IF(NOT(ISERROR(MATCH(A2:A14,IF(B2:B14="Y",A2:A14,0),0))),1,0))
Again, remember to Ctrl+Shift+Enter to make this work.
Tested in Excel 2013 and it works fine.

Filter out all orders of $0 with AGGREGATE function

I was able to find an answer to the question linked below, but now I am interested in adding one more tweak.
I had a list of all orders placed in a time range and was am trying to calculate the difference between each customer's first and second order. I had a list of unique customer IDs on another tab and the first order date for each. I was able to find the difference between first and second order date with the and AGGREGATE formula, but now I would like to also filter out all orders where the "Order Total" is 0.
=AGGREGATE(15,6,Sheet1!C1:C4/(Sheet1!A1:A4 = 153950),2)
Original Question:
Find each customer's second order date in a list of all orders
Try,
=AGGREGATE(15, 6, Sheet1!C1:C4/((Sheet1!A1:A4=153950)*(Sheet1!B1:B4<>0)), 2)
The idea here is that you want to create a simple maths formula that will #DIV/0! on anything you don't want while AGGREGATE ignores errors thus discarding those from consideration. False (for all intents and purposes) is zero and anything multiplied by zero is zero; anything divided by zero is #DIV/0!. Any number divided by 1 (e.g. true x true) remains unchanged.

Indexing an answer limited to after today in Excel

I'm trying to put together a company excel sheet to keep track of the tickets we give out to senior sales to take out clients.
I put together a "Soonest Available Ticket" section to easily ID what games are coming up we still have tickets for. However, we don't give out tickets to every game and so I want to have these formulas return dates only of games that have not happened yet. Right now, they simply return the first unclaimed game which are all in the past.
I've tinkered with a few formulas, but I can't figure out how to only command it to look at dates today or later. Any ideas?
Below, in order, are my original Index formula, and then my attempts to only find upcoming games.
=IFERROR(INDEX(CubsDate,MATCH("Avail*",CubsTicketStatus,0),1),"Filled")
=IF(WhiteSoxDate>NOW(),IFERROR(INDEX(WhiteSoxDate,MATCH("Avail*",WhiteSoxTicketStatus,0),1),"Filled"),"Season Ended")
=IF(WhiteSoxDate>NOW(),INDEX(WhiteSoxDate,MATCH("Avail*",WhiteSoxTicketStatus,0),1),"Season Ended")
{=INDEX(WhiteSoxDate,(MATCH("Av*"&"*">TODAY(),WhiteSoxTicketStatus&WhiteSoxDate,0)))}
Assuming that "CubsDate" and "CubsTicketStatus" are named ranges of cells (the former containing dates and the latter the status, either "Avail" or "Filled"), then perhaps this will do what you want:
{=INDEX(CubsDate,MATCH(1,(CubsTicketStatus="Avail")*(CubsDate>TODAY()),0))}
Note that if there is no matching date after the current date, you'll get an #N/A result (which you could easily test for).
Here's a test I ran:
Note that the data here is in rows 25 - 31. Also, you'll need to format the result as a date.
Hope this helps!
Edit: Here's an explanation of how the Match function is being used. (I edited the answer so that future generations will find it more easily than if I added a comment.)
As a reminder (because I'm old and forgetful), the Match function takes three parms: Lookup Value, Lookup Array, and Match Type. So in
MATCH(1,(CubsTicketStatus="Avail")*(CubsDate>TODAY()),0)
we're looking for a value of 1 with a match type of 0 (exact match). That's the easy part. Our Lookup Array, however, is a little more complex. It consists of two tests multiplied by each other. So in each row, it looks at the value in CubsTicketStatus to see if it is "Avail" and it looks at the value in CubsDate to see if it's after today.
Each of those tests results in either TRUE or FALSE but, when you put them in the context of a mathematical calculation, they are 1 and 0. So if they're both TRUE, then you get 1 * 1, but if either (or both) is FALSE, you get zero. The Match function then returns the first row where both are TRUE -- that is, the first row where tickets are "Avail" and the date is after TODAY().

Resources