?
Solved

populating value in last record based on multiple conditions for every unique value

Posted on 2012-03-28
3
Medium Priority
?
243 Views
Last Modified: 2012-04-08
Dear experts
Need a formulae which checks for every unique value in column A (variable) and at the same check for value not equal to 1 under column B, and then post 10% in column D. IF there are multiple records for a value in column A with column B <>1, then the last record should get the posting.
In addition, if there is only one occurence of a value under column A, then irrespctive of the value under column, 10% will be populated under column D.


the abovemeans that every record will certainly get one 10%.
value-in-the-last-record.xlsx
0
Comment
Question by:Excellearner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 42

Expert Comment

by:dlmille
ID: 37780110
I think this is it.  Please advise:

I added one more criteria.  

If the value in Column A is NOT unique, then if all occurrences are 1, then the last occurrence will get 10%

See attached.

Here's the formula:
=IF($B2=IFERROR(INDEX(INDEX($A$2:$B$14,,2),LARGE(IF((INDEX($A$2:$B$14,,2)<>1)*(INDEX($A$2:$B$14,,1)=$A2),ROW(OFFSET($A$1,,,ROWS($A$2:$A$14))),""),1),1),1),IF($B2=1,IF(COUNTIF($A2:$A$14,$A2)=1,0.1,""),0.1),"")

It is array entered - hit F2 on the formula, then CTRL-SHIFT-ENTER

See attached.


Dave
value-in-the-last-record-r3.xlsx
0
 
LVL 43

Assisted Solution

by:Saqib Husain, Syed
Saqib Husain, Syed earned 1000 total points
ID: 37780254
You can also try a non-array formula

=IF(COUNTIF(A:A,A2)=COUNTIFS(A:A,A2,B:B,1),IF(COUNTIF(A:A,A2)=COUNTIF($A$1:A2,A2),10%,""),IF(B2<>1,IF(COUNTIFS(A:A,A2,B:B,"<>1")=COUNTIFS($A$1:A2,A2,$B$1:B2,"<>1"),10%,""),""))
0
 
LVL 42

Accepted Solution

by:
dlmille earned 1000 total points
ID: 37780283
@ssaqibh - good one.  I originally wrote for Excel 2003 compatibility, then threw in the IFERROR when I noticed the sheet posted was Excel 2007+ to shorten the formula.

Your formula can be shorted a bit with two less ifs and one 10%/"" result respectively:

=IF((COUNTIF(A:A,A2)=COUNTIFS(A:A,A2,B:B,1))*(COUNTIF(A:A,A2)=COUNTIF($A$1:A2,A2)), 10%,IF((B2<>1)*(COUNTIFS(A:A,A2,B:B,"<>1")=COUNTIFS($A$1:A2,A2,$B$1:B2,"<>1")),10%,""))

Dave
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question