Excel find last record of specified value in range - excel

I have a excel formula question.
I have table/range of some accounts activity during days with amounts as bellow
date / account / amount
1-Jan / 20 / 60
1-Jan / 30 / 2
2-Jan / 20 / 3
2-Jan / 20 / 4
3-Jan / 10 / 5
4-Jan / 20 / 6
I want to extract last record of given accounts as bellow
10 -> 3-jan / 5
30 -> 1-Jan / 2
which formulas will find last in range based on criteria?
How Can do it?

In Excel 2016 from a 365 license, you can use the new MAXIF. In previous versions, use an array formula like this in F2 in the screenshot:
=MAX(IF($B$2:$B$7=E2,$A$2:$A$7))
Note that it must be confirmed with Ctrl-Shift-Enter, otherwise it will not work.
Then look up the amount with this formula in G2 in the screenshot.
=INDEX($C$2:$C$7,MATCH(F2&E2,INDEX($A$2:$A$7&$B$2:$B$7,0),))
Copy both formulas down

Related

Sumif of multiple Index matches against one value

Need help regarding Excel dynamically search based sum of two columns matching from two different tables.
I have got this Table of Data Entered One Time
A B C
1 Qlty Warp Weft
2 Stpl.1 150 20
3 Cotn.1 80 60
4 Stpl.2 20 20
5 Cotn.2 20 20
6 Stpl.3 20 40
in Column A2:A6, Quality can not be duplicated, its a unique Name
The Data entry and report Table is here
A B C D E F
8 Yarn Name Sent Bags Remaining Qualty Used Warp Used Weft
9 20 800 600 Stpl.1 71 200
10 150 101 30 Stpl.2 70 30
11 40 300 290 Stpl.3 100 10
12 20 400
C9:C5000 is Returning Column, Values are calculated on the base of Column A9:A5000 (Yarn Name)
Need to Find Yarn Name (eg:) "20" in B2:B6 AND/OR C2:C6, wherever it matches, index that Quality from A2:A6
Then match the returned qualities(could be more than one) to D9:D5000 and sum the mathced results from E9:F5000
I have tried so far in C12
=SUMIF($A$9:$A12,A12,$B$9:$B12)-(SUMIF($D$9:$D12,INDEX($A$2:$A$6,MATCH(A12,$B$2:$B$6,0)),$D$9:$D12)+SUMIF($D$9:$D12,INDEX($A$2:$A$6,MATCH(A12,$C$2:$C$6,0)),$D$9:$D12))
PS:- I am using Excel 2007
If I understand correctly, then following array formula can help you:
=SUM(IFERROR(INDEX($A$2:$A$6,N(IF(1,(MMULT(--($B$2:$C$6=A9),TRANSPOSE(COLUMN($B$2:$C$6)^0))>0)*(ROW($B$2:$C$6))-1)))=TRANSPOSE($D$9:$D$12),0)*TRANSPOSE($E$9:$E$12+$F$9:$F$12))
Array formula after editing is confirmed by pressing ctrl + shift + enter
Edit:
To calculate Warp and Weft columns separately use following array formula:
=SUM(IFERROR(INDEX($A$2:$A$6,N(IF(1,((A9=$B$2:$B$6)*ROW($B$2:$B$6))-1)))=TRANSPOSE($D$9:$D$12),0)*TRANSPOSE($E$9:$E$12))+SUM(IFERROR(INDEX($A$2:$A$6,N(IF(1,((A9=$C$2:$C$6)*ROW($C$2:$C$6))-1)))=TRANSPOSE($D$9:$D$12),0)*TRANSPOSE($F$9:$F$12))

Sum the maximum values based on criteria Excel

The objective is to calculate the total allowance for the kids in my data set that are aged 12+. In this example using the data set below, the outcome should be 9 (5+2+2). Can someone please help me with a formula? Thanks!
ID Age Allowance
Fred 12 6
Fred 15 10
Fred 18 5
Joe 12 2
Sam 12 2
DJ 10 1
With Office 365 Excel:
=SUMPRODUCT(SUMIFS(C:C,A:A,A2:A7,B:B,">=12",B:B,MAXIFS(B:B,A:A,A2:A7))/COUNTIFS(A:A,A2:A7))
If one does not have Office 365 Excel then one can use a helper column and sum that.
In D2 Put:
=IF(AND(B2=AGGREGATE(14,7,$B$2:$B$7/($A$2:$A$7=A2),1),B2>=12),C2,"")
And copy down. Then sum at the bottom.

Create list of row names based on search criteria

I have the following Excel spreadsheet:
A B C D E F G H
1 Q1 Q2 Q3 Q4 Search criteria: 60 Asset 2
2 Asset 1 15 85 90 70 Asset 3
3 Asset 2 40 80 45 60 Asset 3
4 Asset 3 30 60 55 60 Asset 5
5 Asset 4 12 72 25 15
6 Asset 5 60 48 27 98
7
In Cells A1:E6 I have different assets with their performance from quarter Q1-Q4.
In Column H I want to have a list of all assets that match the search criteria in Cell G1. In this case the search criteria is 60 which can be found in the Cells A1:E6 for the Assets 2, 3 and 5.
As you can see it can happen that the search criteria exists mutliple times in a row (like in Row 4). Therefore, I want that the asset is listed two times in the list (like Asset 3).
Do you have any idea of a formula that could create this list?
Try this in H1
=INDEX(A:A,AGGREGATE(15,7,ROW($B$2:$E$6)/($B$2:$E$6=$G$1),ROW(1:1)))
and copy down.
If you are using an older version of Excel this can be done with an array version of SMALL:
=INDEX(A:A,SMALL(IF($B$2:$E$6=$G$1,ROW($B$2:$E$6)),ROW(1:1)))
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.

How to return values until threshold is reached in Excel

I'm struggling to solve a calculation problem in Excel which seems to be harder than I thought.. and I just can't find the approach I need on the internet. I will present a simplified version of what I want to get and would be eternally grateful to whoever can help me get the result.
I have the following row:
100 // 20 / 30 / 10 / 60 / 20 / 80
What I would like to see is:
100 // 20 / 30 / 10 / 40 / 0 / 0
So the first column is a total and for all the next columns, I have time-distributed values that should add up to this total and return the value that is in the cell, and at some point the amount that is needed to equal the 100 in the first cell. After that, the threshold is reached and it should return zero's.
Is there some formula for this I don't know about or an elegant way of solving this problem? Help is very much appreciated!
If you have your first row going from A2:G2 in Sheet1 (100 / 20 / 30 / 10 / 60 / 20 / 80, respectively), you could use the following by entering the formula in cell B2 of Sheet2 and dragging to G2.
=IF(COLUMN(B2)=2,'Sheet1'!B2,IF('Sheet1'!B2+SUM(A2:$B2)>='Sheet1'!$A2,'Sheet1'!$A2-SUM(A2:$B2),'Sheet1'!B2))

Find name of the last cell with data in a row

I've searched for an answer, but it seems that I can only find VBA-based solutions, which appear no longer be an option in Excel 2008.
I'm trying to return the name of the last cell in a row that contains data. It looks like this:
+===========================================================+
A / B / C / D / E (columns)
+===========================================================+
1 || [Formula] / 3 / 4 / 5 / [blank]
2 || [Formula] / 7 / 8 / [blank] / [blank]
3 || [Formula] / 9 / 10 / 11 / 12
(rows)
+===========================================================+
and the end result would look like this:
+===========================================================+
A / B / C / D / E (columns)
+===========================================================+
1 || D1 / 3 / 4 / 5 /
2 || C2 / 7 / 8 / /
3 || E3 / 9 / 10 / 11 / 12
(rows)
+===========================================================+
It looks like your data is sorted from left to right.
If it is, you could start with something like =MATCH(MAX(C4:K4);C4:K4) to retrieve the column index of the last cell (max) of the row. From there, it's easy to buid the address:
=ADDRESS(ROW();MATCH(MAX(C1:K1);C1:K1);4)
Edit: combining ADDRESS with COUNT or COUNTA (great idea from Dustin Geile) does not require the items to be sorted:
=ADDRESS(ROW();COLUMN()+COUNT(B1:Z1);4)
=CHAR(COUNTA(B1:ZZ1) + 65) & ROW()
You can try this arrayformula:
{=ADDRESS(ROW(B2),MAX(IF(ISEMPTY(B2:H2),0,COLUMN(B2:H2))))}
Validate with CtrlShiftEnter
If you are looking for the last cell with data, you can write a quick function and place it in a VBA module in your workbook.
Public Function LastCell(inRange as Range)
LastCell = inRange.End(XlToRight).Address
End Function
Or just omit the '.Address' if you want to get a range object pointing to the cell.
You can then use it in a formula like...
=LastCell(A1)
Regards
Ray

Resources