Sum.if, without nesting 12 sum.if functions - excel

I have a problem with an excel function, i "inherited" from a former colleague.
I have the two tables below:
My goal is to get the green field in Table 2 to show the sum of Person1s earnings from January to December. If months was =11 in Table 2, it should show the sum of Person1s earnings from January to November.
My current formular is a lot of nested "If" and "Sum.if" functions, but i wish to shorten it. Is it possible. I tried to say the sum area in the Sum.If to be all columns with data, but it still just returns the one from january (the first one it finds, i guess)
I hope someone can help me! Sorry for my bad english, but i'm not a native speaker
Best regards
Edit: Current formula by request
=IF(A2=0;0;IF($I$1=1;SUM.IF('Earnings'!A:A;A2;'Earnings'!L:L);IF($I$1=2;SUM.IF('Earnings'!A:A;A2;'Earnings'!L:L)+SUM.IF('Earnings'!A:A;A2;'Earnings'!M:M);IF($I$1=3;SUM.IF('Earnings'!A:A;A2;'Earnings'!L:L)+SUM.IF('Earnings'!A:A;A2;'Earnings'!M:M)+SUM.IF('Earnings'!A:A;A2;'Earnings'!N:N);IF($I$1=4;SUM.IF('Earnings'!A:A;A2;'Earnings'!L:L)+SUM.IF('Earnings'!A:A;A2;'Earnings'!M:M)+SUM.IF('Earnings'!A:A;A2;'Earnings'!N:N)+SUM.IF('Earnings'!A:A;A2;'Earnings'!O:O);IF($I$1=5;SUM.IF('Earnings'!A:A;A2;'Earnings'!L:L)+SUM.IF('Earnings'!A:A;A2;'Earnings'!M:M)+SUM.IF('Earnings'!A:A;A2;'Earnings'!N:N)+SUM.IF('Earnings'!A:A;A2;'Earnings'!O:O)+SUM.IF('Earnings'!A:A;A2;'Earnings'!P:P);IF($I$1=6;SUM.IF('Earnings'!A:A;A2;'Earnings'!L:L)+SUM.IF('Earnings'!A:A;A2;'Earnings'!M:M)+SUM.IF('Earnings'!A:A;A2;'Earnings'!N:N)+SUM.IF('Earnings'!A:A;A2;'Earnings'!O:O)+SUM.IF('Earnings'!A:A;A2;'Earnings'!P:P)+SUM.IF('Earnings'!A:A;A2;'Earnings'!Q:Q);IF($I$1=7;SUM.IF('Earnings'!A:A;A2;'Earnings'!L:L)+SUM.IF('Earnings'!A:A;A2;'Earnings'!M:M)+SUM.IF('Earnings'!A:A;A2;'Earnings'!N:N)+SUM.IF('Earnings'!A:A;A2;'Earnings'!O:O)+SUM.IF('Earnings'!A:A;A2;'Earnings'!P:P)+SUM.IF('Earnings'!A:A;A2;'Earnings'!Q:Q)+SUM.IF('Earnings'!A:A;A2;'Earnings'!R:R);IF($I$1=8;SUM.IF('Earnings'!A:A;A2;'Earnings'!L:L)+SUM.IF('Earnings'!A:A;A2;'Earnings'!M:M)+SUM.IF('Earnings'!A:A;A2;'Earnings'!N:N)+SUM.IF('Earnings'!A:A;A2;'Earnings'!O:O)+SUM.IF('Earnings'!A:A;A2;'Earnings'!P:P)+SUM.IF('Earnings'!A:A;A2;'Earnings'!Q:Q)+SUM.IF('Earnings'!A:A;A2;'Earnings'!R:R)+SUM.IF('Earnings'!A:A;A2;'Earnings'!S:S);IF($I$1=9;SUM.IF('Earnings'!A:A;A2;'Earnings'!L:L)+SUM.IF('Earnings'!A:A;A2;'Earnings'!M:M)+SUM.IF('Earnings'!A:A;A2;'Earnings'!N:N)+SUM.IF('Earnings'!A:A;A2;'Earnings'!O:O)+SUM.IF('Earnings'!A:A;A2;'Earnings'!P:P)+SUM.IF('Earnings'!A:A;A2;'Earnings'!Q:Q)+SUM.IF('Earnings'!A:A;A2;'Earnings'!R:R)+SUM.IF('Earnings'!A:A;A2;'Earnings'!S:S)+SUM.IF('Earnings'!A:A;A2;'Earnings'!T:T);IF($I$1=10;SUM.IF('Earnings'!A:A;A2;'Earnings'!L:L)+SUM.IF('Earnings'!A:A;A2;'Earnings'!M:M)+SUM.IF('Earnings'!A:A;A2;'Earnings'!N:N)+SUM.IF('Earnings'!A:A;A2;'Earnings'!O:O)+SUM.IF('Earnings'!A:A;A2;'Earnings'!P:P)+SUM.IF('Earnings'!A:A;A2;'Earnings'!Q:Q)+SUM.IF('Earnings'!A:A;A2;'Earnings'!R:R)+SUM.IF('Earnings'!A:A;A2;'Earnings'!S:S)+SUM.IF('Earnings'!A:A;A2;'Earnings'!T:T)+SUM.IF('Earnings'!A:A;A2;'Earnings'!U:U);IF($I$1=11;SUM.IF('Earnings'!A:A;A2;'Earnings'!L:L)+SUM.IF('Earnings'!A:A;A2;'Earnings'!M:M)+SUM.IF('Earnings'!A:A;A2;'Earnings'!N:N)+SUM.IF('Earnings'!A:A;A2;'Earnings'!O:O)+SUM.IF('Earnings'!A:A;A2;'Earnings'!P:P)+SUM.IF('Earnings'!A:A;A2;'Earnings'!Q:Q)+SUM.IF('Earnings'!A:A;A2;'Earnings'!R:R)+SUM.IF('Earnings'!A:A;A2;'Earnings'!S:S)+SUM.IF('Earnings'!A:A;A2;'Earnings'!T:T)+SUM.IF('Earnings'!A:A;A2;'Earnings'!U:U)+SUM.IF('Earnings'!A:A;A2;'Earnings'!V:V);IF($I$1=12;SUM.IF('Earnings'!A:A;A2;'Earnings'!L:L)+SUM.IF('Earnings'!A:A;A2;'Earnings'!M:M)+SUM.IF('Earnings'!A:A;A2;'Earnings'!N:N)+SUM.IF('Earnings'!A:A;A2;'Earnings'!O:O)+SUM.IF('Earnings'!A:A;A2;'Earnings'!P:P)+SUM.IF('Earnings'!A:A;A2;'Earnings'!Q:Q)+SUM.IF('Earnings'!A:A;A2;'Earnings'!R:R)+SUM.IF('Earnings'!A:A;A2;'Earnings'!S:S)+SUM.IF('Earnings'!A:A;A2;'Earnings'!T:T)+SUM.IF('Earnings'!A:A;A2;'Earnings'!U:U)+SUM.IF('Earnings'!A:A;A2;'Earnings'!V:V)+SUM.IF('Earnings'!A:A;A2;'Earnings'!W:W);"")))))))))))))

In B16, enter formula :
=SUM(OFFSET(B2,MATCH(A16,A3:A9,0),,,C12))

SUMIF is used to add the contents of a single column that match the criteria.
To achieve what you want, try this:
To shorten the formula significantly
=SUMPRODUCT(($A$3:$A$9=$A$14)*(B3:K9))
I have guessed your row and column numbers, but if you can't get it working just post your row and column headings and I will troubleshoot it.
Alternatively, if you would like to add another table with cumulative earnings, you could do it quite easily.
To provide cumulative earnings for each month for each person
For example, in B15 (or whatever the reference, we can't see your row/column number) you could have "Cumulative Jan", then fill right for a column for the cumulative earnings for each month. In that case B15 would say:
=SUM($B3:B3)
Then fill right and down.
This gives you cumulative earnings for any month for any person, in a table.
You could then do a lookup to that table if you wanted to, to return the matching value given the two inputs of person and month number.

Related

Sum if month is June and row text contains

I'm hoping someone can help with a formula to input the value of Testing for June in cell A20 (FOR EXAMPLE).
So first criteria is the month as Jun-21 and then the next is the word testing.
I need more than a basic sum function as it needs to include the total purely based on the month and the name
If you need to lookup a value using both the row label and column label, using index/match is the formula to use. I assume you only have two different table, so this formula looks up the number in the first table, then looks up the value in the second table and adds them together.
=INDEX(J3:P8,MATCH(B12,J3:J8,0),MATCH(B13,J3:P3,0))+INDEX(A3:G8,MATCH(B12,A3:A8,0),MATCH(B13,A3:G3,0))
Thanks heaps for that!
How about if it were two tables but only some items are in each. So say if testing was only in one table but passing is in both - I hope to be able to use the same sum for all so is there something I can add in to the formula so it knows to just include the one total if it can't see the name testing in the other table?
Would it be somehow incorporating a lookup instead?

Filtering or Importing data for specific date

I was wondering if anyone knows if it's possible to import a data, in a sort of a COUNTIF function but only for the data dated today?
I have 2 sheets, Attendance and Department.
In the Department tab, I have a list of employee's in column A. In column B and so on, I have a drop down option to select which department they're are stationed for each day. Each column represent a day, B being the 1st, C being 2nd, ... and so on. The header for each column has the day for the day as well.
On the attendance sheet, I have the list of Department in column A and in B, it is used to record how many employee are stationed at that department. I also have the day for the day on this sheet on A1.
Is it possible that when I change the date, the number of employee stationed in each department will change according to the date?
Is it possible to do this with just functions?
I've tried using the COUNTIF function, but I've found that I will have to change the range on a daily basis.
Use The Function: in B4 of Attendance Tab
=COUNTIF(INDIRECT("Department!" &ADDRESS(3,MATCH($A$1,Department!$A$2:$P$2,0)) & ":" &ADDRESS(6,MATCH($A$1,Department!$A$2:$P$2,0))),$A4)
Results: Attendance Tab
Department Tab:
I have used all the references as in the screenshots, you can change them if they are different in your sheet.
your question can be solved by SUMPRODUCT function. See below solution picture:
SOLUTION
Just to quickly explain my solution, I gave a name to the date on the Department sheet, called it 'Date_Lookup'; and I gave a name to the dates on the Attendance sheet, called it 'Date_List'. Names will simplify my formula especially when referencing across worksheets.
You will eventually find a lot of COUNIF scenario can be solved by SUMPRODUCT and this is just one example. SUMPRODUCT can do a lot IFs than COUNTIFS can do. In your case there are two criteria, one is which department did an employee attend to, and the other is on which date did the employee attend to that particular department. So my SUMPRODUCT formula can be understood as:
=SUMPRODUCT(('from the list of dates'='the particular date I want to see')*('from the full attendance record'='how many employees went to the given department'))
Let me know if you have difficulties understand my answer. A good 1 hour read through some online articles regarding SUMPRODUCT will help.
Cheers :)
Your first step would be to use a function to work out in which column the entered date appears. So in your Department sheet you enter a date in A1, then set B1 to:
=IFERROR(MATCH(A1, Attendance!2:2, 0), 0)
I use the IFERROR as I don't like seeing errors on my sheet. Assuming the result isn't zero, use a COUNTIF looking for the department letter in a range in the result column. I'd simply use on OFFSET to get the right range, but sticklers would tell you to find a different way of doing it. So long as your spreadsheet isn't going to increase in size to a massive complexity, OFFSET is fine.

Guide me Regarding Compare the Value of Cell contain date and other cell contain Drop down list

Hy Every One, I need help in excel formula, I have two sheets, sheet1 for sale tracker, sheet two for goals tracker, I used Now() to enter date automatically, and its working fine, Next in goal sheet, I use =Sumif() to calcualte various category totals and refer them in cell. Its also working fine. But I want to track record according to month and category. Like I have 6 categories detail is as under,
Sales Tracker
In the First picture Column Date consist of formula "=IF(ISBLANK(B5),"-",TODAY())" and it display the name of month like "October"
While in second picture there is a drop down list of "Month" Column.
1- I want to use if statement like =if(Date=Month, Sum(Revenue Secure column Data), "-") But its not working the formula I wrote here is an example....
2- I want when I select any month from second sheet like January, February, It should calculate sum from picutre one data and only show the sum of january etc.
Please help me, this is eating my brain a huge,,,,,,:)
Thanks in advance....
In short my question is how can I use If statement to compare value of cell that contain formula and other that contain drop down list?
Or use the MONTH function to change your date to a number 1 to 12 corresponding to the month. Then have the combo return a number for the month chosen. It might be faster using integers than test
I Believe you have to compare the month and not the whole date.
You can do TEXT(NOW();"mmmm") to get the full month name of the current data (in the language of excel) and then compare it to your drop down.
If you replace the NOW() with any data it works as well.

In EXCEL: How to calculate percentage of column total, based on month chosen in drop down

In Excel I want to calculate an individual line as a percent of the total column, but I would like to have a dynamic calculation so that I can calculate different columns (or in this case months) based upon a drop down month chosen.
As example in the screenshot below, the word "September" in Cell AH35 is the chosen month, so I want to calculate the percent of each row in the column titled September AC36.
I.E. what percent is .0018 of the total 21.247. And I want this to change based upon the month chosen
Example:
So it looks like you have things like Dec2 and December so Cell AH35 should be a validation list using the range of headers you want this to be able to search for. You then can use Hlookup, Row(), Offset() and Match() to achieve the results. You will need to adjust the range T36:AE45 to match your full range. In offset the 10 is for the number of cells until the total. The hlookup gets the value and the offset portion gets the total. Then format the cells as percentages. The only reason I tackled this is it looked like a nice little challenge. You should really try something for yourself next time and post when you get stuck as we typically do not answer questions that ask us to do it for you, FYI...
Edit: You add this to the end of the row so AH37 through AH45
=HLOOKUP(AH35,T36:AE45,ROW()-ROW(T36)+1,FALSE)/OFFSET(T36,10,MATCH(AH35,T36:AE36,0)-1)

INDEX&MATCH excel on rows and return SUMPRODUCT

I needed some help with Excel functions as I am not really sure how to achieve this.
Basically, this picture shows my data structure:
I am aware that I can use Index& Match excel functions together for columns but I am not sure if it is possible use Index&Match together on two row conditions.
Requirement:
I have three products, product A, product B and Product C. I want to be able to quickly calculate the actual revenue and and you can see the data structure in the image above. My top-most row is month. For each month, I have 4 columns, of which 2 need to be calculated should the condition match.
This is the condition. An example, for product A, calculate the total sumproduct(multiples column actual customers x Price Actuals) for yearMonth 201501.
So basically,first, for product A, it would need to find YearMonth 201501, and when it is found, it should find columns Actual Customers and Price Actuals and return the SUMPRODUCT of Actual Customers and Price Actuals.
Is it possible to do this?
I have searched the Internet a bit and I have not found a solution.
Update:I thought I could post the follow-up question in the same thread insted of Cristiano duplicates... For the accepted answer, in the excel formula, how can it be divided by the total amount of "actual customers" for that month?
Simply adding "actual customers" with a slash before IT does not work.
You need a cell where you specify the month you want to look up. Give that cell the name "TheMonth".
You need a cell where you specify the product you want to look up. Give that cell the name "TheProduct".
Then, assuming your screenshot starts in cell A1, you can use
=SUMPRODUCT($B$3:$I$5*($B$1:$I$1=TheMonth)*(($B$2:$I$2="Actual Customers")+($B$2:$I$2="Price - Actuals"))*($A$3:$A$5=TheProduct))
Next time, please post a link to a workbook. It's not much fun typing in the text and numbers from a screenshot in order to verify a formula.
Here is the workbook with the formula in action.

Resources