How to sum the output of multiple DATEDIF results in Excel - excel-formula

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):

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))

Count distinct values in Excel with multiple criteria (strings)

I have an excel sheet with a large table with 3 main columns (Forward, Reverse and Species).
I need to count distinct species for each pair from Forward and Reverse columns but I can't seem to make it work.
I've tried going around it but the closest thing I found was this: "=SUM(IF(("Jennifer"=$D$6:$D$27)*($B$6:$B$27<=DATE(2011, 1, 31)), 1/COUNTIFS($D$6:$D$27, "Jennifer", $E$6:$E$27, $E$6:$E$27, $B$6:$B$27, "<="&DATE(2011, 1, 31))), 0))", which comes from this website https://www.get-digital-help.com/count-unique-distinct-values-that-meet-multiple-criteria-in-excel/ . Still, it doesn't work when I apply it to my sheet.
I'm a complete newbe with excel so I'm looking for some help please.
I'll drop a print of the sheet as well.
Thanks in advance.
Well, this is the formula, you need to use to get the Sum of Distinct Species
Formula used in cell I21
=SUMPRODUCT(IF(($A$2:$A$27=$H21)*($B$2:$B$27=I$20),
1/COUNTIFS($D$2:$D$27,$D$2:$D$27,$A$2:$A$27,$A$2:$A$27,
$B$2:$B$27,$B$2:$B$27),0))
And Fill Down!

Excel - Replicating a SUMPRODUCT formula with already summed up values

I have a sheet that uses the below formula to arrive at a figure:
=SUMPRODUCT(E12:K12,E23:K23)/M10
To my understanding, it's getting the sum of E12:K12(593+622+636+620+595+583+589) and multiplying that together with the sum of E23:K23(5740+5160+5432+4640+4716+7372+6696); then dividing the result by M10(39,756).
I have 2 new cells that contain the results of the two summed ranges but when I try to replicate the formula with a regular sum, the result is different:
=SUM(IntradayPlan2!D346*IntradayPlan2!D347)/P12
The result should be 604 but it's coming out at 4383. P12 contains the same number as M10 and the 2 cells in the SUM are summing the same values as the original SUMPRODUCT formula is.
For clarity, I'm currently replicating the main sheet a second time to generate this result. It's slowing down the workbook and most of the other detail on the replicated sheet isn't needed, so I'm trying to get rid of it.
I'm sure I'm missing something when it comes to SUMPRODUCT but after an hour of Googling around I can't work it out. Is there a way of replicating the same maths procedure with my new totals instead?
After the great explanation by Gowtham I don't think it's possible to recreate the result of a SUMPRODUCT by using total values of the 2 used arrays.
Those cells actually get their values from another sheet, which I need to keep anyway. So I've created a couple of new rows which puts those figures in a line (their otherwise spread out across the sheet) and have referenced those new groups instead.
=SUMPRODUCT(IntradayPlan2!D355:J355,IntradayPlan2!D356:J356)/O12
And I'm getting the expected result :)

Combining INDEX/MATCH with COUNTIF

I'm working on a sensitive Excel file where I'm not allowed any VBA code, so I have to help myself with basic formulas in Excel. Please note that I am not allowed to add extra columns and the solution has to be in one single cell. What I have are two columns:
Column A has numbers from 1-10.
Column B has numbers from 1-10.
I'd like to know e.g. for all 3's in A, how many 5's are in B.
The result would be as well seen with the use of two filters, but I don't want to do this over and over again, since the size of the columns will only get bigger.
I tried to use INDEX-MATCH command in the COUNTIF, but it's not that simple. The main problem is to define how to look and search in each row and then count/sum/whatever.
Does anyone have any ideas?
Though a function not available in versions of Excel before 2007, it seems:
=COUNTIFS(A:A,3,B:B,5)
met the requirement here.

VBA: Complex VLOOKUP function (two-column match vertically, one-row match horizontally). Advice on method

I'm looking for advice on how to approach a certain problem.
In short, I have a matrix with two descriptive columns to the left (Y-axis) and a range of durations/time periods on the X-axis. The first column include bond types, and the second currency. There are 6 kinds of bonds, and 4 currencies. Every combination can have one of four durations.
The problem is that I recieve the mentioned matrix weekly, and the number of rows is different each time because only non-blank rows are reported. Roughly half of them are blank (no activity since last week)
You don't need a vLookup() formula for this. A simple SumProduct() formula will help you :) See the Snapshot for an example
FORMULA
=SUMPRODUCT((A2:A15="AAA")*(B2:B15="Dollar")*(C2:F15))
SNAPSHOT
Do let me know if this is not what you wanted?
HTH
Sid
To find a value in Excel based on both a column and row value, you will need to use both a vlookup and a match function.
=VLOOKUP($A10,$A$1:$E$6,MATCH($B10,$A$1:$E$1,0),0)
Have a look at the example picture below.
![Example for Lookup & Match Formula][1]
http://pzy.be/v/2/LookupMatch.jpg
B##la

Resources