MAX of mapped criteria unless another value is lower - excel

I asked this question in the past. What I need to do now is List Dan's Bakery in the Entity final column. The original entities go through a mapping table and the MAX limit is in the Limit final column. Here is that formula, {=MAX(IF(ISNUMBER(MATCH($G$2:$G$110,IF('Mapping Table'!$B$4:$B$204=B25,'Mapping Table'!$A$4:$A$204),0)),$D$2:$D$110))}. In the above formula, the lookup value for Match is the Parent Connection (G) column and the mapping table maps any entities with certain names to a parent and the D column would be the Limit 1 as there is a hidden column. Hope that's clear enough.
I want to now write a similar formula so that whichever Entity has the highest limit and WORST risk rating is shown in the Entity final column. Meaning, in the below example, Dan's Groceries would be the entity I want to produce in the Entity final column because it has a credit limit line of 30 and a better rating (the lower the rating, the better). Any ideas?
EDIT (March 21) : I need a formula that will take into account the mapping it will register the above formula as well as take into the account the ratings.
I changed the formula to,
=INDEX($A$1:$A$7,MATCH(MIN((1-IF($B$1:$B$7=B1,$D$1:$D$7)/MIN(IF($B$1:$B$7=B1,$D$1:$D$7)))+IF($B$1:$B$7=B1,$C$1:$C$7)/MAX(IF($B$1:$B$7=B1,$C$1:$C$7))),(1-$D$1:$D$7/MIN(IF($B$1:$B$7=B1,$D$1:$D$7)))+IF($B$1:$B$7=B1,$C$1:$C$7)/MAX(IF($B$1:$B$7=B1,$C$1:$C$7)),0))
but, I am coming across errors. For example, if I changed the Limit column for Other to 30, Dan's Bakery is the result or when I change Dan's Shakes limit to 40 (assuming it will be the correctFinal Entityit seems to be taking the MIN rating as the ultimate decider withDan's Fuel` still as the result.

So if your Limit and Rating worth the same you can scale them to values between 0 and 1. After that simple addition would rate one of Entities as the "winner".
Here is example data and an array formula that can do what you want(Array Formulas are applied with Ctrl + Shift + Enter:
Data:
A B C
Dan's Shakes 25 3
Dan's Groceries 30 2
Dan's Floral 10 2
Dan's Bakery 30 1
Dan's Fuel 20 4
Formula:
=INDEX(A1:A5,MATCH(MAX((1-C1:C5/MAX(C1:C5))+B1:B5/MAX(B1:B5)),(1-C1:C5/MAX(C1:C5))+B1:B5/MAX(B1:B5),0))
Outcome:
A B C D
Dan's Shakes 25 3 Dan's Bakery
Dan's Groceries 30 2
Dan's Floral 10 2
Dan's Bakery 30 1
Dan's Fuel 20 4
EDIT:
And when you introduce a parent your data would look like this:
A B C D
Dan's Shakes Dan Corp 25 3
Dan's Groceries Dan Corp 30 2
Dan's Floral Dan Corp 10 2
Dan's Bakery Dan Corp 30 1
Dan's Fuel Dan Corp 20 4
Something Else Bob Corp 30 2
Other Bob Corp 50 1
Your array formula:
=INDEX($A$1:$A$7,MATCH(MAX((1-IF($B$1:$B$7=B1,$D$1:$D$7)/MAX(IF($B$1:$B$7=B1,$D$1:$D$7)))+IF($B$1:$B$7=B1,$C$1:$C$7)/MAX(IF($B$1:$B$7=B1,$C$1:$C$7))),(1-$D$1:$D$7/MAX(IF($B$1:$B$7=B1,$D$1:$D$7)))+IF($B$1:$B$7=B1,$C$1:$C$7)/MAX(IF($B$1:$B$7=B1,$C$1:$C$7)),0))
Result:
A B C D E
Dan's Shakes Dan Corp 25 3 Dan's Bakery
Dan's Groceries Dan Corp 30 2 Dan's Bakery
Dan's Floral Dan Corp 10 2 Dan's Bakery
Dan's Bakery Dan Corp 30 1 Dan's Bakery
Dan's Fuel Dan Corp 20 4 Dan's Bakery
Something Else Bob Corp 30 2 Other
Other Bob Corp 50 1 Other

Related

SUMIFS excluding two criteria

I'm trying to do SUMIFS with two criteria I want to exclude.
I want to count the amount of fruit sold by all, excluding cherries sold by James.
A
B
C
Qty
Product
Salesperson
5
Apples
James
10
Apples
Jack
15
Apples
Ben
20
Bananas
Ben
15
Bananas
Jack
10
Cherries
James
5
Grapes
Ben
10
Grapes
James
15
Cherries
Jack
20
Melons
Ben
I've tried
=SUMIFS(A:A,B:B,AND(B:B"<>Cherries",C:C"<> James"))
but got an error.
=SUMIFS(A:A,B:B,"<>Cherries",C:C,"<>James")
Also does not work as it doesn't count and Cherries or anything sold by James.
From the data above I would expect 115 as my answer.
subtract the part from the whole:
=SUM(A:A)-SUMIFS(A:A,B:B,"Cherries",C:C,"James")

Question about excel columns csv file how to combine columns

I got a quick question I got a column like this
the players name and the percentage of matches won
Rank
Country
Name
Matches Won %
1 ESP ESP Rafael Nadal 89.06%
2 SRB SRB Novak Djokovic 83.82%
3 SUI SUI Roger Federer 83.61%
4 RUS RUS Daniil Medvedev 73.75%
5 AUT AUT Dominic Thiem 72.73%
6 GRE GRE Stefanos Tsitsipas 67.95%
7 JPN JPN Kei Nishikori 67.44%
and I got another data like this ACES PERCENTAGE
Rank
Country
Name
Ace %
1 USA USA John Isner 26.97%
2 CRO CRO Ivo Karlovic 25.47%
3 USA USA Reilly Opelka 24.81%
4 CAN CAN Milos Raonic 24.63%
5 USA USA Sam Querrey 20.75%
6 AUS AUS Nick Kyrgios 20.73%
7 RSA RSA Kevin Anderson 17.82%
8 KAZ KAZ Alexander Bublik 17.06%
9 FRA FRA Jo Wilfried Tsonga 14.29%
---------------------------------------
85 ESP ESP RAFAEL NADAL 6.85%
My question is can I make my two tables align so for example I want to have
my data based on matches won
So I have for example
Rank Country Name Matches% Aces %
1 ESP RAFAEL NADAL 89.06% 6.85%
Like this for all the player
I agree with the comment above that it would be easiest to import both and to then use XLOOKUP() to add the Aces % column to the first set of data. If you import the first data set to Sheet1 and the second data set to Sheet2 and both have the rank in Column A , your XLOOKUP() in Sheet 1 Column E would look something like:
XLOOKUP(A2, Sheet2!A:A, Sheet2!D:D)

Returning the last item in a subset with excel formula

In this example I would like to mark any customer that has bought a pen most recently(or bottom of the list). I have my data sorted by CustomerID and ServiceDate with the most recent as the last. I would like to be able to mark all of the customer’s transactions only if the last purchase was a pen (333).
I have been trying formulas with COUNTA but, not sure how to do it when relying on a subset of data.
=INDEX(C:C,COUNTA(C:C))
This will give me the last value in a column.
Customer ID Custmer Name Item Number Item Name Date Desired Results
1 Bob 222 Paper 1/1/2016 X
1 Bob 111 Tape 1/1/2017 X
1 Bob 333 Pen 1/1/2018 X
4 Greg 333 Pen 1/1/2015
4 Greg 111 Tape 1/1/2016
6 Chris 111 Tape 1/1/2015 X
6 Chris 333 Pen 1/1/2018 X
8 Luke 333 Pen 1/1/2013
8 Luke 333 Pen 1/1/2014
8 Luke 222 Paper 1/1/2015
8 Luke 111 Tape 1/1/2016
8 Luke 111 Tape 1/1/2018
9 Tom 333 Pen 1/1/2013 X
You can do this by creating an additional column. The additional column will find all customers whose last purchase was a pen using this formula: =IF(AND(C2=333,B2<>B3),B2,"").
The next column will give you your desired output: =IF(OR(B2=$F$4,B2=$F$8,B2=$F$14),"X","").
Thanks to joe I was able to figure this one out.
I still had to make another column.
I put this in column F.
=IF(AND(C2=333,B2<>B3),1,"")
Then in column G.
=IF(AND(COUNTIFS(A:A,A2,F:F,1)=1),"Yes","")
This worked great.

Allocate class based on school ranking

In Excel I am trying to allocate classes to pupils based on their ranking in school. The set of data I have looks like this:
S/N Name LevelPosition
1 Andrea 10
2 Bryan 25
3 Catty 5
4 Debbie 26
5 Ellie 30
6 Freddie 28
I would like to have a formula that could sort the pupils based on the LevelPosition and allocate the class in order of this sequence - A,B,C,C,B,A. Hence the result would be:
S/N Name LevelPosition AllocatedClass
3 Catty 5 A
1 Andrea 10 B
2 Bryan 25 C
4 Debbie 26 C
6 Freddie 28 B
5 Ellie 30 A
This was the sort of thing I had in mind.
Column D is just a ranking from bottom to top:-
=RANK(C2,C$2:C$7,1)
Colum D is adjusted for any ties:-
=D2+COUNTIF(D$1:D1,D2)
Column E is based on the #pnuts formula:-
=CHOOSE(MOD(E2-1,6)+1,"A","B","C","C","B","A")
I've put some ties in to show what would happen. The last two students' allocations are reversed because the second to last has the higher mark.

Get Top Performer by Subgroup Using Index and Match

I am trying to rank names in Column C from largest to smallest score.
Category Score Name Total Rank Apple Rank Orange Rank
Apple 10 Joe Rachel Rachel 0
Orange 15 Don Natalie 0 Natalie
Apple 20 James Tom Tom 0
Apple 1 Rob Nothing Nothing 0
Orange 3 Mary Gina 0 Gina
Orange 100 Rachel James 0 James
Orange 99 Natalie Don 0 Don
Orange 87 Tom Joe 0 Joe
Apple 27 Gina Mary Mary 0
Orange 30 Nothing Rob 0 Rob
This works in Column E for Apples AND Oranges, with formula in E2 that is
=INDEX($C$2:$C$25,MATCH(1,INDEX(($B$2:$B$25=LARGE($B$2:$B$25,ROWS(E$1:E1)))*(COUNTIF(E$1:E1,$C$2:$C$25)=0),),0))
However, the goal is to compare Apples to Apples and Oranges to Oranges.
Only, the formulas in Columns F and G show "0" values for those rows that aren't in the right Apple/Orange category.
For F2:
=IF($A:$A="Apple",INDEX($C:$C,MATCH(1,INDEX(($B:$B=LARGE($B:$B,ROWS(F$1:F1)))*(COUNTIF(F$1:F1,$C:$C)=0),),0)),0)
For G2:
=IF($A:$A="Orange",INDEX($C:$C,MATCH(1,INDEX(($B:$B=LARGE($B:$B,ROWS(G$1:G1)))*(COUNTIF(G$1:G1,$C:$C)=0),),0)),0)
How do I modify the codes so that 0 values won't show up?
Something like this would be great: (screenshot made by just copy pasting values...)
Apple Rank Orange Rank
Rachel Natalie
Tom Gina
Nothing James
Mary Don
Joe
Rob
Note: Unless the whole column ranges are required the steps below may seem to take an uncomfortably long time if these ranges are not restricted.
Assuming you have what below is in ColumnA:G and a corresponding layout:
then ColumnsI:J may be achieved quite simply by copying ColumnF:G and Paste Special..., Values into I1, then select ColumnsI:J, HOME > Editing - Find & Select, Replace..., Find what: 0, Replace with: , Replace All followed by Find & Select, Go To Special..., select Blanks (only), OK, right-click on one of the chosen cells and Delete..., Shift cells up, OK.
To remove the 0s from ColumnF:G only replacing the final 0 in each formula with "" is sufficient.

Resources