Sum values in different rows if they match - excel

I need some help regarding an issue that I was not able to solve. I tried to figure it out but without reaching my goal. This is what I have:
In sheet 1 I have estimated active customers for a period of time, where columns are months and rows are departments/states:
Sheet 1
Then, in sheet 2, I'm forecasting sales and need excel to return values from sheet 1 depending on which month we are kicking-off for each department:
Sheet 2
Of course, the kick-off month may vary for each department and values from sheet 1 should accommodate according to the selected month on column B in sheet 2.
And within C2:I4 I have used this formula:
=IFERROR(IF(C$1>=$B2,INDEX(Sheet1!$B$2:$F$4,MATCH($A2,Sheet1!$A$2:$A$4,0),MONTH(C$1)-MONTH($B2)+1),""),"")
The formula above actually works great when departments are not repeated in sheet 1 but, what would happen if departments are repeated (as shown in sheet 1) and I have to sum values from the same department and show the result on each cell in sheet 2?
I look forward to your kind help!
Thanks!

Try using SUMIF like this:
=IFERROR(IF(C$1>=$B2,SUMIF(Sheet1!$A$2:$A$4,$A2,INDEX(Sheet1!$B$2:$F$4,0,MONTH(C$1)-MONTH($B2)+1)),""),"")

Please try this formula, designed for your Sheet2!C2 cell.
=IFERROR(SUMIF(INDEX(Rodrigo,,1),$A2,INDEX(Rodrigo,,MONTH(C$1)-MONTH($B2)+1)),"")
In order for this formula to work you should declare a named range comprising of your range Sheet1!A2:F4. My formula calls the range Rodrigo. If you choose another name please change the name in the formula accordingly.
You can exclude zero results by adding a further IF condition to the formula. I would prefer to do that via cell formatting, like 0;0;; where the third semi-colon determines that a zero will not be shown. You can also suppress display of zeros for the entire sheet in the worksheet options.

Related

Get the name of column header and export to different excel worksheet

I have to work with different checklists in different Excel workbooks in order to organize the progress.
I made a summary where I set a counter in the number of items that I am missing for different workbooks using the formula shown here:
=SUM(LEN(XXX)-LEN(SUBSTITUTE(XXX,"pending","")))/LEN("pending")
However, in order to not have to consult to each of the workbooks to find out which items are pending to complete, I am requesting some guidance to understand if it's possible to say that:
If item in cell is pending, extract the name to a different cell in my summary.
Here's an example workbook:
Summary example
Thank you
I have Comment and a partial solution.
I am ignoring the the cross workbook issues for simplicity.
Get the basics working and deal with that later.
In the formula
=SUM(LEN(XXX)-LEN(SUBSTITUTE(XXX,"pending","")))/LEN("pending")
the sum function is not used correctly. Sum add up all the numbers in
a list and/or range of cells. You have a expression. It will work but is not needed.
=(LEN(XXX)-LEN(SUBSTITUTE(XXX,"pending","")))/LEN("pending")
should work.
As for the sum of the item tagged with "pending" that can be done with a couple of extra rows that would be hidden in your final sheet.
In the sample sheet. Rows 4 and 5 are intermidate calculation rows that will be hidden for final display.
Row 4 has the same relative formula :
=if(B3="pending",B2,"")
for all cells. It copies the data in row 2 only if row 3 has the word "pending".
The objective is to concatenate all of the non blank details
into one cell. I chose a solution that would with Excel 2003+. (2019 could use TextJoin() as an alternative solution)
in row 5 Cell b5 has
=if(len(B4)>0,B4,"")
Starting with C5 the rest have the relative formula
=if(len(B5)>0,if(len(C4)>0,B5&"+"&C4,B5),C4)
This progressively concatenates the cells together ignoring blank cells.
F5 has the answer needed
C8 has the
=COUNTif(B3:F3,"pending")
To count the number missing
and D8 just points as F5 to pick up the results.
For presentation purposes hide rows 4 and 5.

Adding values to different cells depending on conditions - Excel

I am not very good with excel formulas, and I would need some help with a process I want to implement:
Simplifying things, I have an excel sheet (sheet n°1) with rows like this:
Company name | Price | Date
On other excel sheet (sheet n°2) I have one row for every company, and in each column there are all 12 months. I would need a formula so every time I add a row in the first sheet, the price I add is automatically added to the corresponding company row and in the corresponding month (based on the date) on sheet 2
I am really lost here, I know how to apply simple formulas, but not this, is there a way to add each value to a different cell depending on some conditions?
I forgot to add, that I would need to sum this values in sheet 2, so every time I add a new value, it is summed to the actual value of the corresponding cell.
I hope my english is not to bad, and thank you in advance!! :)
Use SUMIFS()
=SUMIFS($Q:$Q,$P:$P,$A2,$R:$R,">="&EOMONTH(B$1,-1)+1,$R:$R,"<"&EOMONTH(B$1,0)+1)
One caveat to this the month headers must be an actual date in the month desired. This can be formatted any way you want to display. My cells all contain the 1st of each month as their true dates.

Excel - SUM Daily results based on given date range

thank you for taking a minute to help me!
I have 3 sheets, 3 of them with daily data of users, vehicles, and population which is steady, all of them have the same structure:
D column is location and the rest are daily results. Results change every 14 days, that's why for each location you are seeing the same data.
And there's a 4th, where I want to concentrate results from the previous sheets based on data and location - location is D column:
I want to set both start and end date and based on that, sum daily results by location. For example, suppose that Inicio - Start date is 01/03/2020 and Termino - End Date is 05/03/2020, in the second image, where I highlight SUM HERE it should appear 227,340 for 001-L1 Dr. Galvez N.
I already tried SUMIF, SUMIFS, SUMPRODUCT but it doesn´t seem to work.
Any ideas?
What didn't work with SUMPRODUCT? Try this - the result is correct:
=SUMPRODUCT((Sheet1!$E$3:$M$3>=$E$2)*(Sheet1!$E$3:$M$3<=$F$2)*(Sheet1!$D$2:$D$14=D5)*Sheet1!$E$4:$M$14)
I tried to adjust the ranges to your example, but change them if necessary.
I have developed this formula for you (001). Please take a look.
[E5] =SUMIFS(INDEX(Counts1,MATCH($D5,Stops1,0),0),Dates1,">=" & $E$2,Dates1,"<=" & $F$2)
The formula is designed for cell E5 of your fourth sheet. $D5, $E$2 and $F$2 are all on this sheet.
Counts1 is a named range on Sheet1, comprising all the passenger counts, starting from column E, up to the last day of the month and, vertically, from row 4 to as many rows as there are stations.
Stops1 is another named range on Sheet1 D4:[end of column].
Dates1 is a third named range on Sheet1, starting from E2:[end of row]. I would suggest you set up these named ranges to adjust dynamically to the actually used areas of the sheet.
Now, INDEX(Counts,MATCH($D5,Stops,0),0) defines all cells in the row of Counts where the Stop is equal to D5. Of course, this reference changes as you copy the formula down.
SUMIFS takes that range, extracts and sums up the numbers you are interested in.
Now, if you need to extract the same numbers by the same system from 3 different sheets you simply repeat the formula 3 times, concatenating the results with plus signs. That leaves you with the task to set up 9 ranges instead of only 3, each group of 3 on one of your source sheets. By the system I have implied above you would name them Count2, Count3 etc.
That leaves the question of your dates. They must be true dates. Text strings that look like dates won't do. (I guess you know that :-). In the test sheet I set up I entered =DATE(2020,3,1) in E2, [F2]=E2+1 and copied from F2 to the right.

Sum the product of multiple vlookup or index/match results

I have 2 worksheets, one with multiple columns of data where rows are given years and the other columns are values under the headers of names, and the second sheet lists rates by year (column) and by name (row).
I am trying to take each value in a given column of sheet1 and multiply it by the relevant rate (found by matching the year of each row and the name of its column to the table in sheet2) and then sum the products by name, but can only use a single cell to do all this.
So far I've tried SUMPRODUCT and got to =SUMPRODUCT(O$24:O$514,INDEX(Rates!$A$2:$X$200,MATCH(O$23,Rates!$A$2:$A$67,0),MATCH($D$24:$D$514,Rates!$A$2:$X$2,0))) but this seems to fall down at the MATCH($D$24:$D:$514,Rates!$A$2:$X$2,0) part, even entering as an array.
I've currently resorted to a clumsy series of SUMIF(2016)*INDEX/MATCH(2016 rate)+SUMIF(2015)*INDEX/MATCH(2015 rate) etc, but would really like to have forward compatibility without relying on formulae being updated!
slightly simplified image of the workbook, thanks for any help!

Concatenated VLookup comparison for conditional Formatting

I'm looking to create a conditional formatting field which will compare the values of two cells on sheet 2, to then format the correct cell on sheet 1.
To give some background, I have a spreadsheet (sheet1) which gets information from (sheet2). (sheet1) concatenates the Assessment period (B4) with the Subject code (AA12) and the Pupil ID (A15) which in turn is used to look up the corresponding field in sheet 2 to get the information.
=VLOOKUP(CONCATENATE($B$4,AA$12,$A15),sheet2!$F:$M,7,FALSE)
Here, Column F in (sheet2) holds the concatenated field names and column L holds the Grade, I.e A,B,C etc.
Column M in (sheet2) holds the numeric equivalent of that grade, i.e A = 1, B = 2 etc.
The rows in (sheet2) hold information on the target grade and the current performed grade, as picked up from the concat where the assessment period is either 'Target Grades' OR 'Autumn End of Term'.
What I am looking to do is to have the grade in my original cell in (sheet1) to have conditional formatting applied based on if the numeric equivalent of the end of term grades in (sheet2) is <, = or > the target grades.
Im not sure if this is possible and have found some other helpful posts such as this one;
Multi-column vlookup conditional formatting
But my issue is that I have 000's of records so would be very time consuming and data heavy to have a conditional format for each and every record such as proposed;
=IF(sheet2!M12<ODBC!M4,"RED",IF(sheet2!M12=ODBC!M4,"YELLOW",IF(sheet2!M12>ODBC!M4,"GREEN")))
What is needed is to incorporate the VLookup so that this can be calculated all at once and basically smash these two functions together;
=AA15 < vlookup(CONCATENATE($B$4,AA$12,$A15)ODBC!$F:$M,8,FALSE)
=(ODBC!$F:M,8,FALSE)<(ODBC!$F:M,8,FALSE)
Please see the below images FYR
Sheet1;
Sheet2;
I'm not even sure if this is possible and is well beyond the scope of my Excel experience so any help would be very appreciated!
EDIT
I have tried this Formulae for the Green colour;
=VLOOKUP(CONCATENATE($A$2,E$5,$A8),Sheet2!$F:M,8,FALSE)<VLOOKUP(CONCATENATE($B$4,G$5,$A8),Sheet2!$F:M,8,FALSE)
This works but for some reason, when applied to other sections with the same added but with a '>' or '=' for red or orange it seems to break and not format properly.
Any Ideas?
I Have fixed this!
After much looking around it seems as though I was on the right track with the EDITs formulae;
=VLOOKUP(CONCATENATE($A$2,E$12,$A1),ODBC!$F:$M,8,FALSE)>VLOOKUP(CONCATENATE($A$4,E$12,$A1),ODBC!$F:$M,8,FALSE)
After coming back to this after a few days, the formulae seemed to work and I was able to successfully spread across the whole sheet, saving me countless hours of individual formatting! Not sure why this was not working originally, it may have had something to do with my cell selection within the "Use a formula to decide which cells to format"!

Resources