how to sum values by unique condition on MS Excel? - excel

I have two columns one for date and one for value. the date columns have different dates with duplicates date and the values are different with duplicates values. Is there any way to sum just one value of duplicate dates with just one value of other duplicate dates?
I tried sumif, sumifs, countif, countifs functions...

In Office 365:
=SUM(TAKE(UNIQUE(C6:D13),,1))
Which takes the unique rows in the range and takes the first column in the sum.
In older versions:
=SUMPRODUCT((C6:C13/(COUNTIF(D6:D13,D6:D13))))
Where it sums all values but divided by the count of the dates occurring in the range. So if it occurs 3 times it sums 3*500/3 =500
For older Excel this may be calculating faster than the above:
=SUMPRODUCT(C6:C14*(FREQUENCY(D6:D13,D6:D13)>0))
Note that the first range is expanded one row, since frequency results in an array followed by a 0

Related

countifs same criteria in diffrent criteria ranges

Need to countifs values between two dates and need to lookup same criteria in different criteria ranges (columns I,J,K) values.I used below formula in N6.Answer should 3.between given dates how many rows are common for given line no in(M4) between given start and end date.Please advise.
=COUNTIFS(A2:A7,">="&N2,A2:A7,"<="&N3,H2:H7,"PASS",I2:I7,M4,J2:J7,M4,K2:K7,M4)
As long as 33A occurs just once in columns I-K you could use:
=SUMPRODUCT((A2:A7>=N2)*(A2:A7<=N3)*(H2:H7="PASS")*(I2:K7=M4))

Excel formula to calculate the sum of the first n% visible rows in a filtered column

As I stated in the title, I want to calculate the sum of the first n% rows in a filtered column. The total numbers of rows in the column varies due to the filtering options, so my formula must work with different values of n.
For example :
In column A, I have 10 rows that contain values from 10 to 1 ( I sorted them from largest to smallest ).
In column B, I have 10 corresponding rows that contain 2 names: 4 of them contain the value "Tom", six of them contain the value "Jerry". When I filter the whole table and select only the rows that contain the value "Jerry", I want to be able to calculate the sum of the first 20% of the corresponding 6 number values.
This could work without any filtering if you want.
With criteria for column B in E1 and percentage you looking for in F1 with the assumption we want to round up the percentage to integers.
So formula in D1:
=SUMPRODUCT(LARGE((B2:B11=E1)*(A2:A11),ROW(A1:INDEX($A:$A,ROUNDUP(COUNTIF(B2:B11,E1)*F1,0)))))
So, without your data, I came up with this, edit to suit your situation...
So, based on the comment, I did a second version:
The helper column in col C is used with sumproduct to give the result...
You can use the percentile function in AGGREGATE with SUMIFS to do what you want:
=SUMIFS(A:A,B:B,"Jerry",A:A,">="&AGGREGATE(16,7,A1:A10/(B1:B10="Jerry"),0.8))
If you want to use the filter to do the decision:
=SUMPRODUCT(SUBTOTAL(3,OFFSET(A1,ROW(A2:A10)-1,,1))*(A2:A10>=AGGREGATE(16,7,A2:A10,0.8)),A2:A10)

Countifs does not work when a range with multiple column is selected

I need a count if function that counts me the cells that meet a certain criteria. This should be done with countifs. The formula is the following:
=COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";Orders!K:Q;">=1")This formula returns me an value type error.
This formula works well until I introduce the last condition orders!K:Q;">=1"
I would like a formula that counts if the word Ecolab is present in the cell; if the date is after or equal 01/01/2019; if the column U has more or equal than the number 36 and if there is at least a "1" in the cells in the row from column K to column Q. I could do this by easily replicating the countifs several times, (i.e =COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";Orders!K:K;">=1")+COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";Orders!L:L;">=1")+...........+COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";Orders!Q:Q;">=1")
But I would rather not include such a long formula as it would create confusion for the ultimate user of the excel sheet
Per my comment above, you could use SUMPRODUCT (avoid using whole columns for that) or an array with OFFSET like this:
=SUM(COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";OFFSET(Orders!J:J;0;{1;2;3;4;5;6;7});">=1"))
If the count for K:Q should be 1 when there may be more than one cell greater or equal to 1 in a single row then you need to apply OR criteria in a SUMPRODUCT.
SUMPRODUCT formulas should not use full column references; there is too much wasted calculation. The following is for rows 2:99; adjust for your own use.
=SUMPRODUCT(--ISNUMBER(SEARCH("ecolab", Orders!D2:D99)),
--(Orders!B2:B99>=DATE(2019, 1, 1)),
--(Orders!U2:U99>=36),
SIGN((Orders!K2:K99>=1)+(Orders!L2:L99>=1)+(Orders!M2:M99>=1)+(Orders!N2:N99>=1)+(Orders!O2:O99>=1)+(Orders!P2:P99>=1)+(Orders!Q2:Q99>=1)))

EXCEL Get a subset of rows from a column of date without VBA

I have multiple sheets of data with the date in column A and a value in column B.
I want to plot the same shifting date range from all sheets (e.g. the past seven days) - so that I can compare the data in one chart. However, the data's "spacing" isn't always the same, so I can't just plot the same number of rows for each sheet.
I've figured out ways to find the rows I want. This gives the first entry for seven days ago:
=LOOKUP(TODAY()-8,sheet1!A:A,ROW(sheet1!A:A))+1
Then I use the COUNT function to get the last value. Now I want to plot the data in this range.
I've tried named ranges but I can't seem to get it to work. Anybody have an idea?
Best regards,
Andrew
=INDEX(INDEX(A:A,first row number formula):INDEX(A:A,last row number formula),0)
you now have a range of matching dates for column A:A, repeat for column B:B
You could also use the OFFSET function
=OFFSET($A$1,first row number formula -1,0,count of number of cells to return,1)

Excel Formula - Column SUM where two columns match values

I have a table where I need to obtain the sum of one column where the values in two other columns match specific criteria.
What I need would be the sum of the Value column where the customer name matches Customer A and the Order Status matches Complete. For this example the result would be £150.00
I am using Excel 2007.
SUMIFS is available in 2007+
first parameter is what values to sum, the subsuiquent pairs are the range and their criteria.
For your example, it would be
=SUMIFS(D:D,A:A,"Customer A",C:C,"Completed")
You could also summarize the whole table using a pivot table.

Resources