My data is:
I need to calculate a sum of the "col1" and "col2" where "name" is "a": 1+2+5+6 = 14.
Now I am using:
=SUMIF(A:A,"a",B:B)+SUMIF(A:A,"a",C:C)
Is there any better way (eg with arrays)?
Try this, for the sum of values where name is a,
Formula in cell B6 --> Applicable To All Excel Users
=SUMPRODUCT(($A$2:$A$4=$A6)*($B$2:$C$4))
Formula in cell C6 --> Applicable To Only O365 & Excel 2021 Users
=SUM(FILTER($B$2:$C$4,A6=$A$2:$A$4))
Related
In excel I have two columns (A and B) filled with text values and I want to get all the values from the two column into one column (C) and it needs to be dynamic
example:
Column A: {car, plane, boat}
Column B: {bike, motor}
Column C: {car, plane, boat, bike, motor}
I hope someone can help me!
use:
=QUERY(FLATTEN(A:C); "where Col1 is not null")
This will work in both Excel(any version) and Google Sheets: Put this in C1 and copy down till you have enough cells filled to capture both lists maximum lengths:
=INDEX(A:B,IF(ROW($ZZ1)>COUNTA(A:A),ROW($ZZ1)-COUNTA(A:A),ROW($ZZ1)),IF(ROW($ZZ1)>COUNTA(A:A),2,1))&""
With Office 365 Excel:
=LET(
rng1st,A:A,
rng2nd,B:B,
cnt1st,COUNTA(rng1st),
cnt2nd,COUNTA(rng2nd),
sq,SEQUENCE(cnt1st+cnt2nd),
INDEX(CHOOSE({1,2},rng1st,rng2nd),IF(sq>cnt1st,sq-cnt1st,sq),IF(sq>cnt1st,2,1)))
Put that in C1 and the results will spill automatically:
Google Sheets has a FLATTEN function which allows you to do this, but there is no equivalent function in Excel.
There is a workaround though, which does combines the 2 columns in the order of their rows:
This works in Excel Version 2019 or later
=FILTERXML("<a><b>"&TEXTJOIN("</b><b>",TRUE,A:B)&"</b></a>","//b")
=IF(SEQUENCE(ROWS(range1)+ROWS(range2))<ROWS(range1)+1,range1,INDEX(range2,MOD(SEQUENCE(ROWS(range1)+ROWS(range2),,ROWS(range2)-ROWS(range1)),ROWS(range2))+1,SEQUENCE(1,COLUMNS(range2))))
This will stack range2 under range1 in Excel (365) this also works for ranges with 2 columns, or more
If the amount of the rows won't be changed
=IFERROR(INDEX($A$1:$A$3, ROWS(C1:$C$1)), IFERROR(INDEX($B$1:$B$2, ROWS(C1:$C$1)-ROWS($A$1:$A$3)), ""))
ctrl + shift + enter
If the amount of the rows can be changed
=IFERROR(INDEX(INDIRECT("$A$1:$A$"&COUNTIF(A:A,"")), ROWS(C1:$C$1)), IFERROR(INDEX(INDIRECT("$B$1:$B$"&COUNTIF(B:B,"")), ROWS(C1:$C$1)-ROWS(INDIRECT("$A$1:$A$"&COUNTIF(A:A,"*")))), ""))
ctrl + shift + enter
my aim is to convert a massive excel sheet with different projects, employees and hours worked per month into an overview per employee. It should be possible to display the projects the employee is involved in and how many hours he worked per project per month.
The original sheet looks something like this:
I managed to find the projects Person A worked in by filtering through the INDEX/MATCH function. I applied the formula to the whole row where the employees are listed and receive multiple results of projects. My question is how to transform the formula into something more effective to copy all of the matched results (projects) into a column (see 1).
This is what I have so far, if matches the employee name in a certain area; the output is the first match of the project he is involved in:
=INDEX(B2:J3;1;MATCH("Person A";Sheet1!B3:E3;0))
How can I copy this to the bottom cells to copy all of the matched results? Does it help to create an array formula with this?
You can use he following formula in cell B9:
=IFERROR(INDEX($2:$2,SMALL(IF($3:$3=$B$8,COLUMN($3:$3)-COLUMN(INDEX($3:$3,1,1))+1),ROWS(A$1:A1))),"")
It indexes row 2 and looks for the column number of the first match in row 3 that equals the value in B8 (=Person A). When dragging down it will look for the second match ROWS(A$1:A1) will become ROWS(A$1:A2) = 2.
For Person B you can use this formula in cell B14:
=IFERROR(INDEX($2:$2,SMALL(IF($3:$3=$B$13,COLUMN($3:$3)-COLUMN(INDEX($3:$3,1,1))+1),ROWS(A$1:A1))),"")
I hope this is what you where looking for.
PS
if you paste the following formula in cell C9 you will get the sum result for Person A on Project XY in month 10 2019:
=IF(OR($B9="",C$8=""),"",SUMPRODUCT(($B$2:$K$2=$B9)*($B$3:$K$3=$B$8)*($A$4:$A$6=C$8),B4:K6))
Note: That is provided that the value in cell C8 equals the value in cell A4.
I'm having a hard time finding a way to add a second criterion to my array formula.
I have 3 columns that I'm tracking data from and I'm outputting this data onto a separate 'summary' tab.
Tab 1 has the following columns
B (quantity), C (employee name), and D (date)
Tab 2 has the following cells
A3 (daily total), B3 (weekly total), C3 (monthly total)
A7 (daily total for employee mark), A7 (weekly total for employee mark), C7 (monthly total for employee mark)
I created an array formula so that I could count all of the quantities added up over certain date ranges (daily, weekly, and monthly), but I also want to output this data and separate it by the employee also.
I can't for the life of me figure out a way to add this to my current formula or find another way to do it where it accurately can track the daily, weekly, and monthly sums of the quantity column.
I've attached a demo sheet so that you can see what I'm working with.
https://docs.google.com/spreadsheets/d/1iAS_U33lPCr-8xnmfK9WuL5URnK8ovY7V-TlKrrSKdQ/edit?usp=sharing
I really appreciate any help I can get on this.
try:
=ARRAYFORMULA(SUMIFS(Updating!B:B,
WEEKNUM(Updating!D:D), 47,
MONTH(Updating!D:D), 11,
YEAR(Updating!D:D), 2019,
Updating!C:C, "Santosh"))
and for Rina:
=ARRAYFORMULA(SUMIFS(Updating!B:B,
WEEKNUM(Updating!D:D), 47,
MONTH(Updating!D:D), 11,
YEAR(Updating!D:D), 2019,
Updating!C:C, "Rina"))
Is there a formula in Excel that will do a 2-D array lookup in separate worksheets inside a single workbook?
I have three tables formatted identically with different data in the tables. Each table is located in a separate worksheet.
Table 1: Carbon Steel Welding Man-hours (CS)
Table 2: Stainless Steel Welding Man-hours (SS)
Table 3: Aluminum Welding Man-hours (Al)
Note: y-axis: pipe diameter, x-axis: pipe schedule(thickness)
I want the formula to identify the material type (CS,SS,Al) in the "summary sheet", and use the correct "man-hour table" inside the correct worksheet. The formula must then perform a 2-D array lookup (y-axis: pipe diameter, x-axis: pipe schedule "thickness"), and display the correct data from the "man-hour table" in the "summary sheet".
To avoid the Volatile INDIRECT function, use a nested IF to lookup each sheet.
=IF(A5="CS",INDEX(CS!Table,MATCH(...),MATCH(...)),IF(A5="AL",INDEX(AL!Table,MATCH(...),MATCH(...)),IF(A5="SS",INDEX(SS!Table,MATCH(...),MATCH(...)),"")))
Note: Excel formula If is short circuited, so only one INDEX/MATCH will be executed
Use INDIRECT to return the correct sheet and INDEX/MATCH/MATCH to get the correct MH:
=INDEX(INDIRECT("'" & A5 &"'!A:X"),MATCH(B5,INDIRECT("'" & A5 &"'!A:A"),0),MATCH(C5,INDIRECT("'" & A5 &"'!5:5"),0))
I have a spreadsheet of product sales by day. There are thousands of Products that were updated on different days. Each Product is in a separate column (designated by a Product ID). Each row is a different day.
I am looking for a formula that will sum the sales for each product since the day it was updated.
So there are 2 moving parts for the formula, identifying which column to sum by the product ID, and then sum from the date it was updated onwards. I have been able to isolate the Date row using
*=MATCH(F159,Sheet!A:A,0)*
and the Column reference using
*=SUBSTITUTE(ADDRESS(1,K159,4,1,),"1","")*
but I haven't been able to incorporate these into a formula that will then sum.
Any help would be grreatly appreciated, thanks!
It's probably easiest to do with a SUMIF formula, so assuming you have a specific product in column H then you can use this formula to sum for that product for sales on and after a specific date
=SUMIF(A:A,">="&Y2,H:H)
where your reference date is in Y2
Now you want the product to be dynamic too so with a specific product in Z2 you can expand that SUMIF like this to get the sum column dynamically
=SUMIF(A:A,">="&Y2,INDEX(B:X,0,MATCH(Z2,B$1:X$1,0)))
so that will find the correct column to sum, assuming product data in columns B to X (expand as required) with product name in row 1
Making a few assumptions as to your variable formats, try this:
Sub Macro1()
row = MATCH(F159,Sheet!A:A,0)
col = SUBSTITUTE(ADDRESS(1,K159,4,1,),"1","")
lastrow = Range(col).End(xlDown).Row
Set rng = Range(col & Row & ":" & col & lastrow)
Range("B1").Value = Excel.WorksheetFunction.Sum(rng)
End Sub
Did you try PivotTables in Excel?