Complex Multi-Conditional IF Function, return value - excel

I need some help returning a desired figure with a complex formula. I've included a sample table with some dummy data, and have almost reached the solution which returns the correct true/false conditions but need some help printing the figure. My brain is a bit frazzled after working on this for a while...
PROBLEM:
I need to print the figure (6000/3000/0) based on not only calculation rule, but also return 0 if the calculated was already printed at the first instance.
RULES
Method Saving (Column E) is calculated using the methodology:
For each university with the same Product (col B), and same Agreement Year (col C), where Total (col D) returns: (6,000 if over 12,500 / 3,000 if under 12,500 / 0 if total = 0)
That is quite easy to achieve ^ -- however, the tricky part comes in when trying to only print the method saving figure once for each entry of the same university, same product and same agreement year.
Looking at the example table below, rows 2 & 3 both have the same university, product and agreement year. It's quite easy to produce a formula with multiple IF statements to print the calculation of either 6000/3000/0, however I only want to print the method saving figure once, at the first instance, following that the method saving figure should be 0.
Worth noting that in Row # 4, 6000 will be printed because even though University and Product are the same, the Agreement Year is different.
Row 1
University (col A)
Product (col B)
Agreement Year (col C)
Total (col D)
Method Saving (col E)
2
Manchester University
Photoshop
2022-2023
20,000
6,000
3
Manchester University
Photoshop
2022-2023
20,000
0
4
Manchester University
Photoshop
2021-2022
14,000
6,000
5
Manchester University
Photoshop
2021-2022
14,000
0
6
Oxford University
Illustrator
2022-2023
8,000
3,000
7
Cambridge University
Figma
2022-2023
0
0
8
Cambridge University
Linux
2022-2023
13,000
6,000
9
Bristol University
Linux
2022-2023
0
0
10
Coventry University
Lightroom
2021-2022
20,000
6,000
11
Coventry University
Lightroom
2022-2023
10,000
3,000
12
Coventry University
Lightroom
2022-2023
10,000
0
13
Coventry University
Photoshop
2022-2023
4,000
3,000
I have already worked on a potential solution, which may not be the most efficient, but for times sake it has gotten me the furthest. I've edited the cell references to match the dummy data table.
=IF(OR(AND(E1<>"",B2<>B1,C2<>C1),AND(E1<>"",D2=D1,C2<>C1)),
OR(AND(A2=A1,B2=B1,D2<12500,D2<>0),3000,
OR(AND(A2<>A1,B2<>B1,D2<12500,D2<>0),3000,
OR(AND(A2=A1,B2<>B1,D2<12500,D2<>0),3000,
OR(AND(A2<>A1,B2=B1,D2<12500,D2<>0),3000,
OR(AND(A2=A1,B2=B1,D2>12500,D2<>0),6000,
OR(AND(A2<>A1,B2<>B1,D2>12500,D2<>0),6000,
OR(AND(A2=A1,B2<>B1,D2>12500,D2<>0),6000,
OR(AND(A2<>A1,B2=B1,D2>12500,D2<>0),6000,
OR(D2=0,0,0))))))))),0)
The above formula when entered will correctly return TRUE or 0 based on the criteria above, so it has managed to figure out the logic behind it -- I'm just now having trouble at the very end to print the respective figure (6000/3000/ or importantly 0 if either Total is 0 or the figure has already been printed)
Let me know if you have any ideas / need me to clarify anything!
Thanks!

Try this in E2 and fill down:
=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,B2,$C$2:C2,C2)=1,VLOOKUP(Sheet3!$D2,{0,0;1,3000;12500,6000},2),0)
I used a lookup table to determine what to return, and a COUNTIF to only return a non-zero if the entry is the first that matches those first three columns.

Related

Excel --- Tried many time but fail

enter image description here
I want to sum all these data given in right side to my format. I tried many time and many formulas but some things left every time. Please help
You can achieve most of what you need with a mixture of formulae and a pivot table. But I couldn't quite get everything you wanted, as some of it doesn't make sense. For example, you have 2013 - 2012 - <5 as your first row header, but there are multiple years that give an age less than 5, e.g. 2014 - 2013 - <5 would also be valid. I would suggest hardcoding the years somehow, as they aren't entirely relevant anyway?
Breaking it down into separate problems.
How do I get the Roman number version of the Class?
You could have a massive IF statement, but I went for a VLOOKUP. You could have used the ROMAN built in function, but you can't because your numbering is "first", "second", etc. instead of "1", "2", etc.
So I actually went for both solutions, just to show how they both work. First I created a named table (list object) called "Named" that looks like this:
Class Class Number
First 1
Second 2
Third 3
Fourth 4
etc.
I then used this to VLOOKUP your class names and convert them into numbers. Next I used the ROMAN function to make this into roman numeral format. So I ended up with this (columns E, F and G in my worksheet):
Class Class Number Roman
First 1 I
First 1 I
First 1 I
First 1 I
First 1 I
Second 2 II
Third 3 III
Fourth 4 IV
With formulae:
Class Number - =VLOOKUP(E2,Named,2,FALSE);
Roman - =ROMAN(F2).
How do I get from "Male"/ "Female" to "B"/ "G"?
This was trivial, just =IF(A2="Male", "B", "G") where I have Gender in column A.
How do I get the "age text" so it handles "<5" and ">22"?
My age was in column D, so this was also trivial, =IF(D2<5,"<5", IF(D2>22, ">22", D2)).
Now I have enough data to pivot, so I selected my entire table, which was basically your sample data with calculated columns added to the right. Then I inserted a pivot table and dragged in row/ column headers to make it match your format. This doesn't give you the year columns, but it gives you everything else. For example, just using a few random rows of sample data (as I couldn't be bothered to type it all in):
I went from:
Gender Date of Birth Age Class
Male 06-Jan-14 4 First
Female 07-Sep-11 6 First
Male 01-Jan-12 6 First
Male 31-Dec-12 5 First
Female 01-Oct-11 6 First
Female 16-Nov-10 7 Second
Male 31-Oct-09 8 Third
Male 25-Oct-10 7 Fourth
To:
I II III IV
B G G B B
<5 1
5 1
6 1 2
7 1 1
8 1
Total 3 2 1 1 1
From here you could simply hardcode the columns A and B from your desired final format, as these years aren't actually based on the data?

Excel Vlookup Multiple Values

I am looking for a vlookup formula that returns multiple matches using two lookup values. I am currently trying to use the concatenate method, but I haven't quite figured it out. The table needs to return all of the multiple matches not just one. Currently, its only returning the last match.
For example, lets say I have a list of multiple city and states. The cities differ but the states remain the same obviously. I want to return the number of people in the each city.
City State #OfPeople
Albany NY 10
Orlando FL 5
Tampa FL 3
Seattle WA 1
Queens NY 8
So I concatenated the city and state column.
Join City State #OfPeople
Albany-NY Albany NY 10
Orlando-FL Orlando FL 5
Tampa-FL Tampa FL 3
Seattle-WA Seattle WA 1
Queens-NY Queens NY 8
The purpose of this is to create an updated log of people in each city has time progresses. I want to have a grand total amount of people in each column. (I know this requires another formula. I'm just focused on returning multiple matches for now). However, I don't want to overwrite the existing data. Hopefully, I explained this well. This is just an example of a larger project I'm working on. I need to be able to build on this list. That's why its important that I be able to return matches multiple times.
Join City State #OfPeople Total
Albany-NY Albany NY 10 10
Orlando-FL Orlando FL 5 15
Tampa-FL Tampa FL 3 18
Seattle-WA Seattle WA 1 19
Queens-NY Queens NY 8 27
Any help would be greatly appreciated!
Considering you're trying to get some grand totals based on multiple criteria, I would suggest using SUMIFS() / COUNTIFS() functions, rather than focusing on searching matching row itself.
However, if you need multiple criteria look up, for some reason, I believe INDEX() + MATCH() combination can perfectly do the job.
The table needs to return all of the multiple matches not just one.
Currently, its only returning the last match
You'll need to use SUMIFS() if there are multiple records for the same city/state combo in your people lookup.
=SUMIFS (sum_range, range1, criteria1, [range2], [criteria2], ...)
Let's assume that you have a cities tab and a people tab. Let's assume you have ten cities that you want to return the total amount of people from.
Cities Tab definition
City range: 'Cities'!A$1:A$10
State range: 'Cities'!B$1:B$10
People Tab definition
City range: 'People'!A$1:A$100
State range: 'People'!B$1:B$100
#OfPeople range: 'People'!C$1:C$100
Drop this formula in the first row of your cities tab, drag down the entire range of cities.
=SUMIFS('People'!C$1:C$100, 'Cities'!A$1, People'!A$1:A$100, 'Cities'!B$1, 'People'!B$1:B$100)

Load item cost from an inventory table

I have an Inventory Sheet that contains a bunch of data about products I have for sale. I have a sheet for each month where I load in my individual sales. In order to calculate my cost of sales, I enter my product cost for each sale manually. I would like a formula to load the cost automatically, using the product name as a search term.
Inventory Item | Cost Sold Item | Sale Price | Cost
Product 1 | 2.99 Product 3 | 16.99 | X
Product 2 | 4.99 Product 3 | 14.57 | X
Product 3 | 6.99 Product 1 | 7.99 | X
So basically I am looking to "solve for X".
In addition to this, the product name on the two tables are actually different lengths. For example, one item on my Inventory Table may be "This is a very, very long product name that goes on and on for up to 120 characters", and on my products sold table it will be truncated at the first 40 characters of the product name. So in the above formula, it should only search for the first 40 characters of the product name.
Due to the complicated nature of this, I haven't been able to search for a sufficient solution, since I don't really know exactly where to start to quickly explain it.
UPDATE:
The product names of my Inventory List, and the product names of my items sold aren't matching. I thought I could just search for the left-most 40 characters, but this is not the case.
Here is a sample of products I have in my Inventory List:
Ford Focus 2000 thru 2007 (Haynes Repair Manual) by Haynes, Max
Franklin Brass D2408PC Futura, Bath Hardware Accessory, Tissue Paper Holder, ...
Fuji HQ T-120 Recordable VHS Cassette Tapes ( 12 pack ) (Discontinued by Manu...
Fundamentals of Three Dimensional Descriptive Geometry [Paperback] by Slaby, ...
GE Lighting 40184 Energy Smart 55-Watt 2-D Compact Fluorescent Bulb, 250-Watt...
Get Set for School: Readiness & Writing Pre-K Teacher's Guide (Handwriting Wi...
Get the Edge: A 7-Day Program To Transform Your Life [Audiobook] [Box set] by...
Gift Basket Wrap Bag - 2 Pack - 22" x 30" - Clear [Kitchen]
GOLDEN GATE EDITION 100 PIECE PUZZLE [Toy]
Granite Ware 0722 Stainless Steel Deluxe Food Mill, 2-Quart [Kitchen]
Guess Who's Coming, Jesse Bear [Paperback] by Carlstrom, Nancy White; Degen, ...
Guide to Culturally Competent Health Care (Purnell, Guide to Culturally Compe...
Guinness World Records 2002 [Illustrated] by Antonia Cunningham; Jackie Fresh...
Hawaii [Audio CD] High Llamas
And then here is a sample of the product names in my Sold list:
My Interactive Point-and-Play with Disne...
GE Lighting 40184 Energy Smart 55-Watt 2...
Crayola® Sidewalk Chalk Caddy with Chalk...
Crayola® Sidewalk Chalk Caddy with Chalk...
First Look and Find: Merry Christmas!
Sesame Street Point-and-Play and 10-Book...
Disney Mickey Mouse Board Game - Duck Du...
Nordic Ware Microwave Vegetable and Seaf...
SmartGames BACK 2 BACK
I have played around with searching for the left-most characters, minus 3. This did not work correctly. I have also switched the [range lookup] between TRUE and FALSE, but this has also not worked in a predictable way.
Use the VLOOKUP function. Augment the lookup_value parameter with the LEFT function.
        
In the above example, LEFT(E2, 9) is used to truncate the Sold Item lookup into Inventory Item.

Change format of Excel

So I'd like to essentially transpose the format of an Excel file. The original format is below:
**2015-03-08 2015-03-08 2015-03-15 2015-03-15**
**brand_code All New bookings Average Lead Time All New bookings Average lead time**
Brand A 2 7.84 4 4.54
Brand B 6 9.63 9 2.34
I'd like to convert this format to the one shown below:
Category 2015-03-08 2015-03-15
All new bookings(Brand A) 2 4
All new bookings(Brand B) 6 9
Average Lead Time(Brand A) 7.84 4.54
Average Lead Time(Brand B) 9.63 2.34
I'd like to do this in Excel itself preferably. I do not want to write any R or other code for this. Some easy-to-use freeware would be acceptable.
First unpivot (there is a step-by-step guide and other references here) then add a column on the left and move/copy or fill it with All New bookings / Average Lead Time repeating to suit and label that Category. Concatenate the first to two columns into a third if desired. Now create a new PivotTable with layout to suit.

Count and average data inside categories under two types of conditions

I'm working on Excel with a lot of data and I'm having difficulty with knowing how to sort through it to get some important numbers. I have minimal Excel experience.
Right now I'm struggling with knowing how to get the average in the difference between two columns. The trick is that I have to get the average in difference when column A is less that column B and then, the same when it's more. And all that within a category.
So for example let's say I have 3 categories: Football, Soccer, and Basketball (these are just made up ones).
So in column A, I have: Soccer, Football, Basketball. Then, in column B and C, I have the scores for John and Adam for the last 3 months, respectively. Lastly, in column D, I have the differences between their scores.
So, for example:
Category John Adam Differences
Soccer 5 3 2
Soccer 6 2 4
Soccer 3 5 2
Soccer 4 0 4
I want to create a table for within each category I have a table like below:
Nº of cases Avg. Difference between John and Adam
When John's score is >
When John's score is <
When they are equal
Is there some type of formula where I can say something like this:
If the category is Soccer (the category being in column A), take the difference between John's score (column B) and Adam's score (column C) when John's score is larger than Adam's score, then calculate the average of those differences? Then, I would use the same formula but tweak it when John's score is smaller.
Additionally, would there be a formula where I can also, calculate within the category Soccer, how many times John's score is bigger than Adam's?
My data is much larger and I can't do this manually.
A B C D
1 Sport John Adam Differences
2 Soccer 5 3 2
3 Soccer 6 2 4
4 Soccer 3 5 -2
5 Soccer 4 0 4
6 Basketball 20 15 5
7 Basketball 7 13 -6
8 Basketball 26 10 16
9 Basketball 8 11 -3
Type in D1:
=B1-C1
Drag the formula in Column D to all rows which there are values in columns A, B and C.
Create the PivotTable.
Drag Sport to "Row Label" field. Drag Differences to "Row Label" field under Sport.
Drag Differences to "Values" field as: Count of Differences (same way the previous question)
Drag Differences to "Values" field (below Count of Differences), and set the mathematical operation as "Average" of Differences (left-mouse click Differences, choose "Values fields settings" and select "Average").
Give a right-click mouse in cell A5 (see picture bellow) and select "Group" option.
Set "Starting at" = 0; "Ending at" = 1000; "By" = 1000 (as in the picture below). Click ok.
You will have in each Sport, the count (frequency) and average Differences values for two groups:
When the Difference B1-C1 is negative; and
When the Difference B1-C1 is zero or positive.
The average of Differences when the score is equal will be always zero.

Resources