Success rate based on date - excel-formula

I'm a total excel noob. I'm trying to find "Today's Success rate" based on 2 columns. One column is the date of an attempt, the other is success/fail. I have a formula for getting the overall success rate, but it just uses one column. I need to get today's success rate. There are other columns, but don't worry about those.
The problem I'm having is finding a different column cell value from a result of searching the date column. SO, find today's date in column A, then sum up the true values from column B and divide by total.
| Date Col A | Success Col B |
| ------------- | ------------- |
| 4/1/2019 | true |
| 4/1/2019 | false |
| 4/2/2019 | true |
| 4/2/2019 | false |
| 4/2/2019 | true |
| 4/2/2019 | false |
| 4/2/2019 | false |
This is the formula I have for calculating the overall success rate
=100*COUNTIF(B2:B1000,"true")/SUM(COUNTIF(B2:B1000,"true"), COUNTIF(B2:B1000,"false"))
Assuming today is April 2, 2019, the above table should have
Today's Success Rate: 40%

=COUNTIFS($A$3:$A$9,$D$2,$B$3:$B$9,TRUE)/COUNTIF($A$3:$A$9,$D$2)
This should work. I put "today's date" in cell D2 so make sure you adjust the formula accordingly. Another thing to note is make sure that your true false entries in column B are in the same format as it is in the formula (meaning all caps or no caps).

With text values in cols A and B, use:
=SUMPRODUCT(--(A:A="4/2/2019")*(B:B="true"))/SUMPRODUCT(--(A:A="4/2/2019"))

Related

Excel formul to count Table Range using month from date text

I have an excel workbook where I am trying to count the number of apples in a named table. The workbook has multle sheets each named Jan, Feb, Mar, etc. with a corresponding table range of the same name.
My main worksheet has a list of months as columns and fruit as rows, I want to use a countif or suitable function to count the number of each fruit per month using the column heading as the worksheet portion of the formula.
This is what I have tried, this works, but has to be manually coded for each month, i would prefer it be more dynamic.
=COUNTIF(JAN[Labels],$A2)
Note: A2 contains the word apple
I have tried to get the month from the column date but it doesnt work
=COUNTIF(TEXT(E25,"mmm")[Labels],$A2)
This is roughly what the "master" table should look like (for clarity)
| | Jan-20 | Feb-20 | Mar-20 | .... |
| Apple | 4 | 3 | 5 | ... |
| Pear | 5 | 4 | 9 | ... |
EDIT:
Just to assist with anyone trying to help, this is roughly what a table on another sheet will look like:
| invoice | labels|
| 12535 | Apple |
| 12536 | Pear |
| 12537 | Apple |
This table would be a named table of Jan or Feb, etc.
Please try this:-
=COUNTIF(INDIRECT(TEXT(G2,"mmm")),"A")
G2 contains a proper date.
Here is a variation of the above where column 2 of the table is specified as the range to count in.
=COUNTIF(INDEX(INDIRECT(TEXT(G2,"mmm")),0,2),"B")
If you must use column captions to identify the column I would suggest MATCH to find it.
OK, so I found an answer, combining the above answer by Variatus with an additional new row.
| A | B | C | D |
1| | Jan-20 | Feb-20 | Mar-20 |
2| |JAN[Labels]|FEB[Labels]|MAR[Labels]| <- =UPPER(TEXT(B1,"MMM"))&"[Labels]"
3|Apple | 5 | 7 | 3 | <- =COUNTIF(INDIRECT(B$2),$A3)
4|Pear | 7 | 2 | 9 |
5|Orange| 1 | 3 | 3 |
So formula in B2 makes an uppercase text value of the month from B1 plus the column name Labels.
The formula in B3 (and down) counts the number of instances of the fruit from the named table & column shown in B2.

Calculating Time Between Time/Days In Excel

I am having some difficulty finding the optimal solution to a problem I am having with Excel. Right now, I have a large sheet which has time on one axis (column A is every date between 1/1/2018 to 1/1/2019), and in the sheet I have time using the h:mm:ss function in different cells on different intervals.
For example, for rows 1/1/2018 - 1/3/18, there is a starting time on 1/1/2018 (example, 8:00:00), and then an ending time on 1/3/18 (example, 16:00:00).
The time between those two dates and two times on those dates is what I am looking to calculate.
This is on a sheet with 2000+ rows, and each interval is different (some may be three days, some may be the same day). The difference between all of these is another column with location. This looks like:
Row 2) Date, Location [A], Arrival Time (8:00:00), Departure Time (blank)
Row 3) Date (the next day), Location [A] (the same as above), Arrival time (blank), Departure Time (16:00:00)
+---+----------+----------+---------+-----------+
| | A | B | C | D |
+---+----------+----------+---------+-----------+
| 1 | Date | Location | Arrival | Departure |
| 2 | 1/1/2018 | A | 8:00 | |
| 3 | 1/2/2018 | A | | 16:00 |
| 4 | 1/3/2018 | B | 8:00 | 16:00 |
| 5 | 1/4/2018 | C | 5:00 | 13:00 |
| 6 | 1/5/2018 | C | 5:00 | 10:00 |
+---+----------+----------+---------+-----------+
I need to calculate the time spend in Location [A] between Arrival time on one date to the Departure time on the next date.
Please let me know what you think the optimal solution is to this problem, I am open to anything!
+--------+----------+---------+-----------+------------------------+
| Date | Location | Arrival | Departure | Time Spent in Location |
| 1/1/18 | A | 8:00:00 | 16:00:00 | 8:00:00 |
| 1/2/18 | B | 8:00:00 | | |
| 1/3/18 | B | | 18:00:00 | 34:00:00 |
| 1/4/18 | C | 8:00:00 | | |
| 1/5/18 | C | | | |
| 1/6/18 | C | | 16:00:00 | 56:00:00 |
+--------+----------+---------+-----------+------------------------+
The post from above is dead accurate - The trouble I am having is from the time intervals for each location being different (and random). I am trying to simply have an additional column which calculates the time spent in each location - from there I will be collecting data on each location and how many hours will be spent there.
Also, a big THANK YOU for the help so far! I am shocked by how quickly comments were made - sorry for the time it took me to make the mock-up, hope it helps make my goal in this more clear.
Actual Snip from sheet
One possible solution is to use the following formula in E2 and copy down.
=IF(C3="",((A3+D3)-(A2+C2)),IF(D3<>"",D3-C3,""))
EDIT: D4-C4 changed to D3-C3 in formula above)
It works by combining the date to the time, doing a math operation as needed and then stripping it out. Tap in a couple of IF statements to deal with rows that are single line locations, or the arrival only. It also assumes the first entry cannot be a departure.
Credit to urdearboy for the correct custom formatting. You will need to format the cells of the column to be [h]:mm
OPTION 2
This assumes that locations can be repeated. The use of a helper column is used to create a unique combination.
In F2, use the following formula and copy down as required:
=COUNTIFS($B$2:B2,B2,$C$2:C2,"<>"&"")
The $ locking the cells is very important. Note how it creates an expanding range as you copy down.
now technically speaking you can combine the following into one monster formula, but it will be difficult to follow and therefore maintain if someone else has to deal with it or you come back to it at a much later date. So on that note I will break it into 2 more helper columns and formulas
In column G we will identify the first row where a unique location occurs. A unique location is created by compounding the location name and the unique ID number which is a count of how often it has occurred in the list so far. Ie. A1 is the first time there was an arrival at location A, E2 is the second arrival at location 2. In G2 place the following formula and copy down.
=AGGREGATE(15,6,ROW($A$2:$A$16)/(B2&F2=$B$2:$B$16&$F$2:$F$16),1)
Now that the arrival row is identified the same needs to be done for the departure row. The same formula can be used but change the 15 to a 14. In H2 place the following formula:
=AGGREGATE(14,6,ROW($A$2:$A$16)/(B2&F2=$B$2:$B$16&$F$2:$F$16),1)
Now that you have those locations identified, you can use the following formula to calculate time:
=IF(D2="","",(INDEX(A:A,H2)+INDEX(D:D,H2))-(INDEX(A:A,G2)+INDEX(C:C,G2)))
In the example, I placed it in I2 and then I copied F2:I2 down as required. but it could be placed in E2 and copied down just as easily.
If you do not want those additional helper columns in G and H, then you can substitute them into your formula for time and it will look like this:
=IF(D2="","",(INDEX(A:A,AGGREGATE(14,6,ROW($A$2:$A$16)/(B2&F2=$B$2:$B$16&$F$2:$F$16),1))+INDEX(D:D,AGGREGATE(14,6,ROW($A$2:$A$16)/(B2&F2=$B$2:$B$16&$F$2:$F$16),1)))-(INDEX(A:A,AGGREGATE(15,6,ROW($A$2:$A$16)/(B2&F2=$B$2:$B$16&$F$2:$F$16),1))+INDEX(C:C,AGGREGATE(15,6,ROW($A$2:$A$16)/(B2&F2=$B$2:$B$16&$F$2:$F$16),1))))
A tidied up version using the monster formula and therefore not needing column G and H formulas:
Remember to apply custom formatting to your time calculation column of [h]:mm

Excel difference between two columns

I have this question that puzzles me. Two columns of unique text entries in a worksheet all having a number next to each of them.
How can I compare the values for each pair of text and find the ones where the associated numbers are NOT the same.
Not even sure how the output would be. Maybe using Conditional Formatting highlighting the value in the first column where the match in the second one is different???
Thank you for your time.
Let's have some sample table.
+-----+---+-------+---+------------------------------------+
| A | B | C | D | =VLOOKUP(C1;ALL_VALUES;2;FALSE)=D1 |
+-----+---+-------+---+------------------------------------+
| abc | 1 | fasfa | 4 | #N/A |
+-----+---+-------+---+------------------------------------+
| aa | 2 | abc | 1 | TRUE |
+-----+---+-------+---+------------------------------------+
| dd | 3 | dd | 2 | FALSE |
+-----+---+-------+---+------------------------------------+
Where ALL_VALUES is named range of you table (here A1:D3). Formula returns TRUE when match is found, else it return False Or #N/A(You can transform #N/A by IfError function). Then you can filter the result in table based on this or you conditional formatting... Depends on what suits you better ;)

Dynamically construct range to use in XIRR formula

I have a sheet in this form:
Fund | Date | Amount
A | 10-Jan-05 | -5000
A | 10-Feb-05 | -5000
A | 08-Oct-13 | 12500
B | 10-Sep-05 | -5000
B | 10-Oct-05 | -5000
B | 10-Nov-05 | -5000
B | 08-Oct-13 | 22500
I'm looking for an output column that provides the XIRR for each fund. The XIRR function takes values and dates as ranges. I need a way to dynamically construct the range using the fund name as a search criteria.
Fund | XIRR
A | ...
B | ...
I could manually specify the range for each fund after sorting it by name, but its not a scalable solution.
You can use OFFSET to get the correct ranges, e.g. this formula
=XIRR(OFFSET(C$2,MATCH(A11,A$2:A$8,0)-1,0,COUNTIF(A$2:A$8,A11)),OFFSET(B$2,MATCH(A11,A$2:A$8,0)-1,0,COUNTIF(A$2:A$8,A11)))
see screenshot

Excel Column Formula with Conditional Value

I have a summary table like this:
Total Pay | Amount Unpaid | Total Left
It is based on a table with the following format:
Date | Hours | Pay | Paid
... | 5 | 100.00 | Yes
... | 4 | 80.00 | No
... | 6 | 120.00 | Yes
I am trying to create a formula that will fill in the Amount Unpaid column.
I have this so far which gives me the error: 'Error in Value':
=SUM(IF(Sunshine!E5:E6,Sunshine!D5:D6,0))
You can use the SUMIF function:
=SUMIF (E2:E5, "No", D2:D5)
This will add all values in D2:D5, but only if the corresponding row in E2:E5 equals "No".

Resources