finding the closest match based on multiple criteria - excel

Ive been working on VBA at work for almost a year and have managed to pull of some rather impressive things, normally I can find anything I'm not sure about with a series of searches on this site or others but this time I have come up blank, I guess its most likely because I don't really know how to frame the search properly :(
I'm looking to create a macro that analyses a customers sales history, then preforms a 'you might also like' search from our bestsellers list and returns the closest match to their bestseller. The product is books and due to many decades of bibliographic attention to detail within the industry each product can have up to 20 categories and I want to use this to find the closet match.
The info I have (the important bits)
Sheet 1 - product id - customer sales quantity
Product id 2 -customer sales quantity
Product id 3 -customer sales quantity
Etc etc ( usually up to 100)
Sheet 2 - product id - total company sales quantity
product id2 - total company sales quantity product id3 - total company sales quantity
Etc etc (Currently over 34000 and growing...)
Sheet 3 - cat1 cat2 cat3 cat4 cat5 cat6 etc (to cat400)
Product id 1 0 1 1 0 0
Product id2 0 1 1 0 1 0
Product id3 1 0 1 1 0 0
What I want to be able to is to find the bestseller from the customers list, look up all of the matching categories for that product on the cat reference table, find all results with an exact match to those categories and list them by total company's sales value. Although it is very possible that with the amount of possible categories there will not be an exact mach so I would like then to get the closest match of that product.....
Does that make sense? Please let me know if any more info is needed to help - even just a pointer towards some kind of function or a snippet of code that will help me on my way would be appreciated, I just have no idea how to find a match for an entire rows values.... and even less of an idea of how to find a closest match if there are no exacts...

Interesting question. There's no match function to achieve what you want. Instead, you need to first figure out what kind of algorithm/logic you want to use in order to determine the closest books. This will require a lot of weighing. Here's how I'd do it (without VBA):
Let's use the following data as example:
Approach:
Combine product info with overall sales info, to have a weight for each book:
Determine to the "average preference" of the customers basket in sheet1. In order to do so:
Add the category information for the 400 categories to each product in the basket:
Sum each category for all basket products (see row 6 above)
Determine the weigh (see row 7).
Apply this preference to all products to determine the overall fit:
Compare each product's categories with the preference:
Check that the product is not already in the basket:
Combine all three factor to determine each product's fit (by multiplying the factors) - and rank them using the RANK function:
Last but not least, retrieve the top X highest matches with a lookup:
Here's the sample file.

Related

Rank the best (highest value) combinations based on individual and grouped options

I have a project where people can bid on 6 products individually or for multiple products for a higher value.
For example, someone may bid for Product 1 and offer $2 or Product 4 and offer $6 or Product 1 & 4 and offer $9.
We have bids for all products individually but need to consider mixes where grouped offers are also considered and remaining products are sold individually.
Our goal is to create a ranked list the highest value options.
Does anyone have any ideas or experiences doing something similar and how did you go about it?

excel PowerPivot Auto Calculated Measures & Columns

After looking at a few similarish questions I figured I needed something more specific so asking here. I will start by explaining the situation:
The Setup
I have a Store which sells Cakes, Cookies and Wine. I have the weekly sales data of each product sorta like this:
Product ID
Product Name
Quantity
Value
Week Ending
1
Ginderbread
2
£4
13/01/22
2
Chocolate chip
5
£25
13/01/22
3
Red Wine Bottle
1
£10
13/01/22
4
Sponge Cake
3
£9
13/01/22
Currently every week's data is stored within the same table, with me using a Week filter to show only the week i'm interested in.
Using this Data I created PivotTables that shows the sales of each category, with the ability to drill down to show the specific products. Table looks something like this:
Category
Quantity
Value
Cakes
2
£4
Cookies
7
£29
Wine
1
£10
The issue
I now want to stick in a new calculated column that shows the Value as a %. E.g The total value for the previous table was £43, so Cookies is about 67%. If I drill down, it would show the Chocolate Chip record as 80% and Gingerbread as 20%
I imagine doing this would be easier if each individual week's data was on a different table, but I got a lot of weeks and I also want to do tables showing the sales for over a period of time. Plus I don't know of a way to merge the "value" and "quantity" columns, etc instead of having 1 for each week being shown.
any advice would be appreciated
Create an extra column in the source table (prior to filtering) entitled "perc" calculated as the corresponding value for each row divdied by the total value across all rows (se pic. / eqn. for first row below) --
=E2/$E$6
No calculated fields required - just include perc as the mesaure of interest in your pivot table, with value setting as 'sum':
The reason why this worked is because of the common denominator - which allows one to sum ratios on a 1:1 basis.
Devising a calculated field using the standard 'fields, items & sets' functionality for ordinary pivot tables would not be feasible / possible as far as I am aware. You would need to move into the realm of power pivots and data models - which is not too complicated (readily accesible directly from the field list per below) - however, I see this as unnecessary complication for the task at hand.
Side notes:
Using table names in your functions is sometimes more convenient when entering, albeit may appear tricky at first when reviewing - first eqn above becomes:
=[#Value]/Table1[[#Totals],[Value]]

How do I decrement quantity by line in Excel?

New user on Stack Overflow, apologies for my lack of Excel knowledge.
Essentially I have a spreadsheet with all of our customer orders including order number, item SKU, and quantity sold on that order (see pic for example). To estimate profit margin on each of the lines, I'm trying to assign a vendor cost to the orders for each of the vendors.
For example, if we ordered 150 of SKU ABC1 from Vendor1 and 200 of SKU AB1 from Vendor2, I want to assign the cost of Vendor1 to as many orders of that SKU that equal 150, then finish with cost from Vendor 2 for the rest. This will give us an estimate of how much margin we're making by vendor.
Is each order specific to a Vendor? For example, Order 1 is for Vendor 1, Order 2 is for Vendor 3, etc.
If so, you could add the vendor to each order and then use a VLOOKUP to lookup the cost of the SKU for the given vendor. Then it should just be COST * QTY.
Also new here; otherwise, I would have just left a comment.

Conditions in Excel for calculations?

I currently have the following dataset:
What i would like to calculate is the following:
How can i find a way of extracting the number of times a company has only used 1 product, 2products, 3 products etc
The values in the rows are just the counts (so the amount of times a company used that product e.g. 1 means they used product once, twice means product 2 times etc)
So in the dataset image example
Company 1 has only used 1 product, i would like to apply this to the entire dataset, where only 1 product has been used. This is the same for company 2 as only 1 product was used but 3 times, so an output would say something like "2" - which corresponds to the amount of companies that have only used 1 product
And for example where there is more than one product used such as company 3, i would like to have it read "3" the amount of companies that used 3 products
etc
Any ideas
Please see my propsed outcome below:
Thanks
Add a new column PRODUCT_COUNT with the following formula, and drag down.
=COUNTIF(B2:I2,”>0”) to count the number of products utilized by each company more than zero times.
In your example you have 7 companies. So in your summary table, you could do another COUNTIF like so:
=COUNTIF($H$2:$H$8,1)
to count how many companies used exactly 1 product.
=COUNTIF($H$2:$H$8,2) to count how many companies used exactly 2 products.
=COUNTIF($H$2:$H$8,”>=3”) to count how many companies used 3 or more products.
If the number of companies changes, you would need to adjust the size of the range. A named range in the PRODUCT_COUNT column may be a good idea.
=COUNTIF(PRODUCT_COUNT,”>=3”)

Excel Pivot Table - Averaging by Category

I'm trying to create an average by category in a pivot table. This is the first time I've created a pivot table so sorry if the answer is staring me in the face. My raw data looks like:
Date, Transaction type, Description, Paid out, Paid in, Balance, Category
Mar-13, Visa, SHOP, £4.44, , £X, Gifts
Mar-13, Visa, SHOP, £5.00, , £Y, Children
Mar-13, Visa, SHOP, £6.00, , £Z, Gifts
Mar-13, Visa, CLOTHES SHOP YORK, £8.00, , £A, Clothing
Mar-13, Visa, FOOD SHOP, £11.96, , £B, Food
My pivot table shows the information rolled up by Month and grouped by a category:
Row Labels Sum of Paid out Sum of Paid in Sum of Difference
2013
Jan £Jan £Jan £C
Food 1 2 -
Car 2 3 -
Cash 6 6
Feb £Feb £Feb £D
Food 1 2
Car 8 0
Cash 2 3
The categories/data is made up in this case, but the desired outcome I'm after is to get an annual average, informing me how much comes in/out on average across the year per category... looking something like:
Row Labels Sum of Paid out Sum of Paid in Sum of Difference
2013
Avg £AvgIn £AvgOut £AvgDiff
Food 1 2 -
Car 5 1.5 -
Cash 4 4.5
Jan £Jan £Jan £C
Food 1 2 -
Car 2 3 -
Cash 6 6
Feb £Feb £Feb £D
Food 1 2
Car 8 0
Cash 2 3
Is this possible to achieve using a pivot table, as I can't seem to find a way to this at the moment using Excel 2010.
Since it appears that your raw data is already grouped by month, you're able to do this pretty easily. You need to re-arrange your data, however -- the months and the categories need to be on different axes. For example, Category as ColumnLabels, with Values then Month as Row Labels. Then right-click one of the normal values for Paid Out, choose "Summarize Value As...", you'll see SUM is currently checked, just change to AVERAGE. Repeat for one of the Paid In values. The labels should change to help let you know if it worked.
Note that this will NOT work effectively if your source data comes in daily, for example. With only one entry per month, the SUM and the AVERAGE of the single entry are identical. This would not be the case if your raw data was daily (and you still grouped by month) -- you'd be switching from a monthly total to a daily average.
I am currently using LibreOffice, which is just the free version of Excel on a mac. It is basically the same thing, but anyways, do you see the top bar where it says =AVERAGE(B8,C8,D8)? Well, that is how you can incorporate the functions within the table. This is actually a pivot table I had to do for my Java class. All you have to do is click on the cell you want to edit, type =, the function name, (in your case, AVERAGE should be fine) and then any other kinds of functions you use. Hope this helps you out.

Resources