Sumproduct for conditional sum based on rows and columns - excel

I have table formatted as show below:
I'd like to write conditional sum formula in cell F15 to calculate sum based Year, Country, Product together.
I try to use sumproduct to complete this task, but I was only able to calculate sum based on 2 variables: Year and Country.
=SUMPRODUCT((A3:A11=C15)*(C1:Z1=E15);C3:Z11)
Is there a way how to add 3rd variable into this sumproduct formula? Or is there another way to complete this task (I can't change formating of the table).

I didn't have a problem when I tried it - as long as the first part of the SUMPRODUCT works out to an array with the same dimensions as the second part, it should be OK.
=SUMPRODUCT((A3:A11=C15)*(B3:B11=D15)*(C1:Z1=E15);C3:Z11)

Related

Averaging data across multiple columns based on criteria (excel)

I have a spreadsheet (Office 365 Pro) that has numeric data in multiple columns. I want to average data in those columns if specific multiple criteria is met in other columns.
For example, one formula that is in use:
=AVERAGEIFS(K:K,C:C, ">=01/01/2021", C:C, "<=1/31/2021")
This formula works exactly the way I want, for the data specifically only in column K.
I want to accomplish what this formula does, but to include columns K through P, and not K only.
I tested a simple average formula which worked fine across multiple columns
=AVERAGE(K:P)
I can't figure out how to average data in all of those columns based on the criteria in my other formula.
If I simply change the column to average to:
=AVERAGEIFS(K:P,C:C, ">=01/01/2021", C:C, "<=1/31/2021")
I get a #VALUE error.
Any suggestions on how to accomplish this?
use FILTER:
=AVERAGE(FILTER(K:P,(C:C>=DATEVALUE("01/01/2021"))*(C:C<=DATEVALUE("1/31/2021"))))

Finding the sum of dates using first column value

So I am working in excel and have two columns, as shown below.
What I wish to do is to able to get the sum of yearly deadlines for A, B and C.
So that:
Get a sum of dates within Year 2020 for each Variable
Get a sum of dates within Month/Year for each specific A,B and C.
Currently, I have been using a long approach. I use a Vlookup for each row getting a filtered table for each Variable. Then using that I filter out Dates using combination of Countif and Countifs. But the problem with that approach is that I end up getting huge rows and table of data in the end increasing the file size.
I have also tried to use sumproduct() but I do not have numbers so I can not find a sum.
Is there a smart way of doing it using one formula?
Thank you.
Use SUMPRODUCT. For year/variable:
=SUMPRODUCT(($A$2:$A$13=E2)*(YEAR($B$2:$B$13)=$F$1))
for month/year/variable:
=SUMPRODUCT(($A$2:$A$13=$E2)*(YEAR($B$2:$B$13)=$F$1)*(MONTH($B$2:$B$13)=G$1))

Have A Dynamic Sum Function in Excel

So, I feel like I'm trying to do something fairly simple in Excel here. My company has a Spreadsheet with 2 columns and an indefinite number of rows. Column A is the Date, Column B is a production number for that date. At the bottom of Column B is the total production number. However, every time we update the spreadsheet we have to update the formula to include the newest data on every page. We insert columns for the new dates, so is it possible to have a function that changes based on it's current coordinate? For example something like =SUM(B3:B(CurrentRow-1)).
Use this:
=SUM($B$3:INDEX(B:B,ROW()-1))
It is non volatile and will sum everything from B3 to the row in Column B above where the formula is placed.
Hi You can use the below excel formula to achieve the result you are looking at.
If the values you want to sum up is in column B, then type the below formula and it will show the value dynamically when ever you have added a value to the column.
=SUM(INDIRECT("B2:B"&COUNTA(B:B)-1))

Excel using COUNTIFS Function to create a Punchcard

In my data source I have a column that contains the Dates of occurrences and a Column that contains the Hour of the same occurrences.
With this, the goal is to obtain a punchcard plot (maybe the bubble chart will be the most appropriate)
The intermediate structure has the weekday(Sunday-Saturday) as rows (A2:A8), and the hours (8-22) as Columns (B1:P1), as each column must have the occurrence count for a week day in an hour.
With this said, I tried to use the COUNTIFS function, using the following approach, for the cell B2:
=COUNTIFS(WEEKDAY(RawData!T2:T9852;1);A2;HOUR(RawData!U2:U9852);B1)
However, Excel is not computing the value, finding a problem on the formula, having also tried using the Insert Formula Option.
place the following in B2
=SUMPRODUCT((WEEKDAY($T$2:$T$8,1)=WEEKDAY($A2,1))*(HOUR($U$2:$U$8)=HOUR(B$1)))
you will need to convert the , to match the ; on your system
In your range A2:A8 enter a known date for monday such as 2017/08/20. Then select A2:A8 and apply custom formatting for the number format and set it to ddd. This will display the day of the week in text but keep the value in the cell a number.
Adjust the ranges to suit your data.
Copy the formula to fill in your table.

Using an excel formula on filtered cells?

I have the following excel spreadsheet:
The elevation is increasing in ascending order. The distance is culmulative. Criteria is a separate formula which can be explained here:
Selecting values in a list based on an interval?
I want to calculate the slope which is the difference in elevation divided by the difference in distance, but only for the values that have a criteria of "1". Here is a picture showing the spreadsheet filtered and cut where I get the expected values of slope:
I want to perform this formula on the unfiltered list and to get the desired result in the third image.
Are there any formula operations in excel that can perform this task? Can it be done in VBA?
You can add 2 helper columns to your table like so:
Col D tracks the last Elevation that met your criteria. Similarly, Col E selects the last Distance that met your criteria. This keep COL F's formula super simple.
Note this is a variation on Alan's comment, but I prefer the legibility and maintainability of the additional columns to the expert level (and lengthy) formula.

Resources