finding the cheaper price in excel - excel

I have a table in the following format
ID Price
123 £12.99
123 £13.00
123 £12.99
456 £21.99
456 £20.90
789 £18.99
789 £16.99
I'm trying to find the cheaper price based on the ID and the expected output should be in the following format
ID Price Cheap
123 £12.99 Cheaper
123 £13.00
123 £12.99 Cheaper
456 £21.99
456 £20.90 Cheaper
789 £18.99
789 £16.99 Cheaper
I'd like to know how to implement this in excel/googlesheets?

You can use a MIN IF array function in Excel for this. The formula I entered in C2 is:
=IF(B2=MIN(IF(A$2:A$8=A2,B$2:B$8,"")),"Cheaper","")
Note that because it's an array formula, it must be committed with CTRL + SHIFT + ENTER.

For the following setup
Formula in C2 is
=ArrayFormula(IF(B2=MIN(IF(A2=$A$2:$A$8,$B$2:$B$8)),"Cheaper",""))

No need for nasty array formulas here:
=IF($B2=MINIFS($B$2:$B$8,$A$2:$A$8,$A2),"Cheaper","")

Related

Google sheets formula to get the Top 5 List With Duplicates

I'm trying to compile a best 5 and worst 5 list. I have two rows, column B with the number score and column C with the name. I only want the list to include the name.
In my previous attempts the formula would get the top/bottom 5 but as soon as a duplicate score appeared the first known name with that value would just repeat.
Here is my data
26 Cal
55 John
55 Mike
100 Steve
26 Thomas
100 Jaden
100 Jack
95 Josh
87 Cole
75 Brett
I've managed to get the bottom 5 list formula correct. This formula works perfectly and includes all names of duplicate scores.
Example of what I get:
Cal
Thomas
John
Mike
Brett
=INDEX($C$56:$E$70,SMALL(IF($B$56:$B$70=SMALL($B$56:$B$70,ROWS(E$2:E2)),ROW($B$56:$B$70)-ROW($B$56)+1),SUM(IF($B$56:$B$70=SMALL($B$56:$B$70,
ROWS(E$2:E2)),1,0))-SUM(IF($B$56:$B$70<=SMALL($B$56:$B$70,ROWS(E$2:E2)),1,0))+ROWS(E$2:E2)))
Here is the formula I've tried to get the top 5 - however I keep getting an error.
=INDEX($C$56:$E$70,LARGE(IF($B$56:$B$70=LARGE($B$56:$B$70,ROWS(E$2:E2)),ROW($B$56:$B$70)-ROW($B$56)+1),SUM(IF($B$56:$B$70=LARGE($B$56:$B$70,
ROWS(E$2:E2)),1,0))-SUM(IF($B$56:$B$70<=LARGE($B$56:$B$70,ROWS(E$2:E2)),1,0))+ROWS(E$2:E2)))
Example of what I'm looking for
Steve
Jaden
Jack
Josh
Cole
You can set two queries like this for both cases:
=QUERY(B56:C70,"Select C order by B desc limit 5")
=QUERY(B56:C70,"Select C order by B limit 5")
Use SORTN() function like-
=SORTN(A1:B10,5,,1,1)
To keep only one column, wrap the SORTN() function with INDEX() and specify column number. Try-
=INDEX(SORTN(A1:B10,5,,1,1),,2)

Insert a 0"zero" infront of number for specify number sequences

I have this data
Name | Code | Price
XXX 102 1000
YYY 4321 1150
ZZZ 202 1150
AAA 123 1000
I can now Add concatenate and Add 0 in front of Code which makes
0102
04321
0202
0123
Now here the problem lies. I dont want that 0 in front of 4321 . I want 0 only infront of 3 digit numbers not more than 3 digit.
Right click on Column, go to Format cell-->Custom and write 0000 in the type and click on Ok
Simplest and easy solution
Assuming the '102' data is located at B2, just type :
=IF(len(B2)<=3,"0"&B2,B2)
will do. Alternatively, using concatenate() function you may do it like this :
=IF(len(B2)<=3,CONCATENATE("0"&B2),B2)
Assuming you have codes in B column
if(len(b2)=3,concatenate("0",b2),b2)
If you want to write formula then this would be better,
=REPT(0,4-LEN(A1))&A1

How to lookup a value in a table and then return multiple values for when the condition is true?

I have been trying to work with the LOOKUP, LOOKUPROW, LOOKUPCOLUMN (don't know if this is the right word in english excel) to find multiple values that are correct and then return the values in another cell. For example:
col A Col B Col C
Charlie 123 45 Stockholm
Dennis 123 46 Stockholm
Jonas 123 45 Stockholm
I would like to in a cell where i put in 123 45, then i would like a formula that looks in to the columns A, B and find "123 45" and then returns the name "Charlie" and "Jonas". Right now when using Lookup, i only get the last name (Jonas"). Anyone know how to do this?
Best regards
AgatonSaxx

IFERROR, INDEX, MATCH returning zeros instead of blanks

I am using the following formula:
=IFERROR(INDEX('Cleaned Post'!W:W,MATCH(Combined!$C2,'Cleaned Post'!$C:$C,0))," ")
This formula is working beautifully, except that for blank cells, it's returning "0". I would like blank cells to be return as blank.
Specifically, this is what I have
Sheet 1 (entitled Cleaned Post)
Name Email Age Gender Task #1
Andrew 888#gmail.com 18 1 80
Jason 687#gmail.com 20 1 95
Judy 432#gmail.com 18 2 __
Jack 236#gmail.com 24 1 65
Sheet 2 (entitled Combined) - What I'm getting
Email Task#1
888#gmail.com 80
687#gmail.com 95
432#gmail.com 0
236#gmail.com 65
Sheet 2 (entitled Combined) - What I want
Email Task#1
888#gmail.com 80
687#gmail.com 95
432#gmail.com __
236#gmail.com 65
What do I need to do to adjust this formula?
What sort of values is your formula returning? If they are text values it's sufficient to concatenate a "null string" to your INDEX/MATCH formula like this:
=IFERROR(INDEX('Cleaned Post'!W:W,MATCH(Combined!$C2,'Cleaned Post'!$C:$C,0))&"","")
That also works for numbers except it will convert them to text so if you don't want that you can try this version:
=IFERROR(IF(INDEX('Cleaned Post'!W:W,MATCH(Combined!$C2,'Cleaned Post'!$C:$C,0))="","",INDEX('Cleaned Post'!W:W,MATCH(Combined!$C2,'Cleaned Post'!$C:$C,0))),"")
I realize this is an old post, but...
I settled for using conditional formatting..
if the returned value was 0, change the text color to match the background...

Replacing SUMIFS in Excel 2003

So, I need to find an Excel 2003 substitute for =SUMIFS, which is only 2007+ (apparently).
The formula is used to generate this summary data table, from a list of revenue, where each revenue line has the field type (static, email or outreach) and the field fund (ABC, QRS and XYZ).
type fund total count average
static ABC $12,390.88 171 $72.46
email ABC $6,051.32 65 $93.10
outreach ABC $8,835.00 138 $64.02
static QRS $12,925.44 79 $163.61
email QRS $9,305.44 99 $93.99
outreach QRS $1,799.00 49 $36.71
static XYZ $4,912.20 36 $136.45
email XYZ $75.00 2 $37.50
outreach XYZ $0.00 0 #DIV/0!
This is the formula
`=SUMIFS('revenue'!G:G,'revenue'!AH:AH,Sheet2!A2,'revenue'!AI:AI,Sheet2!B2)`
Where G is a dollar amount, and AH and AI are matching the type or fund column.
How do i get this to work in Excel 2003?
The way I ended up getting past this was to create a column that combined the two columns I needed to check (ABCstatic, ABCemail, etc.) Doing it this way allowed me to use just one 'SUMIF' (using two SUMIF clauses linked together results in OR-ing of the conditions, rather than AND-ing).
=SUMIF(Revenue!AJ2:AJ6400,Sheet2!A2, Revenue!G2:G6400)
=SUMPRODUCT(((Revenue!$AH2:$AH10=Sheet2!A2)+(Revenue!$AI2:$AI10=Sheet2!A2))*(Revenue!$G2:$G10))
I don't think you can use full columns with SUMPRODUCT, so you'll have to pick a range sufficiently large. Or use some dynamic range names.

Resources