Conditions in Excel for calculations? - excel

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”)

Related

Label X of Y counting formula

I am struggling from some time now to create a formula in excel and also in gsheets... for a major problem:
we have orders from a online marketplace
in one order define by ORDER ID... we can have maybe one product... sometimes multiple products...
...this is how export orders look like:
i need to create count for printing labels for each order... based on qty and also number of products... 1 of 5, 2 of 5, 3 of 5... so on... to verify all the products for entire order (same ID)...
those count labels are based on total qty and total no of products.... in one order...
is a similar thing for AWB delivery/expedition for courier.... multiple destination, multiple/different numbers of boxes for each destinations...
can u help us with a formula or a way to create those counting labels?

Efficiency question with excel using index match for each cell in a large sheet

I have a 4 types of customers, each pay in a different payment plan.
group 1 - monthly
group 2 - semi monthly
group 3 - bi weekly
group 4 - weekly
I have a sheet with a range of all the relevant payment dates for those group sorted in the right order in row 1
I would like that for each customer there will be a data validation list (group 1,group 2, group 3,group 4)
When selected the customer's row will populate on the correct dates according to his group number and the date the payment starts.
My work around to do that was to create 4 separate sheets for each group, auto populate from the correct date and run it for all customers in each group meaning you can see for John Doe what and when will be his payments in each group even though he is in group 3 for example. And a MAIN sheet where John Doe has group 3 selected where a MATCH and INDEX is running to find when he is supposed to pay and how much. The issue is that for 400 rows and 300 column this becomes heavy.
How would you go about solving that?
each cell looks like this in the MAIN sheet
=LET(mothlydate,Monthlyrd3!$BK$3:AAC$3,semidate,Monthlyth16!$BK$3:ZZ$3,namemonthly,Monthlyrd3!$BK79:AAC79,namesemi,Monthlyth16!$BK79:ZZ79,
IF(OR($BA96="Monthly 3 rd",$BA96="Semi-Monthly",$BA96="Monthly 16 th"),
IF((IF(IFERROR(INDEX(namemonthly,1,MATCH(GH$2,mothlydate,0)),"")+IFERROR(INDEX(namesemi,1,MATCH(GH$2,semidate,0)),"")>$AE96,$AE96,IFERROR(INDEX(namemonthly,1,MATCH(GH$2,mothlydate,0)),"")+IFERROR(INDEX(namesemi,1,MATCH(GH$2,semidate,0)),"")))=0,"",(IF(IFERROR(INDEX(namemonthly,1,MATCH(GH$2,mothlydate,0)),"")+IFERROR(INDEX(namesemi,1,MATCH(GH$2,semidate,0)),"")>$AE96,$AE96,IFERROR(INDEX(namemonthly,1,MATCH(GH$2,mothlydate,0)),"")+IFERROR(INDEX(namesemi,1,MATCH(GH$2,semidate,0)),"")))),
IF($BA96="Bi-Weekly 1",(IFERROR(INDEX(NewBiWeekly!$BK79:AAC79,1,MATCH(GH$2,NewBiWeekly!$BK$3:AAC$3,0)),"")),IF($BA96="Bi-Weekly 2",(IFERROR(INDEX(NewBiWeeklyTwo!$BK79:AAC79,1,MATCH(GH$2,NewBiWeeklyTwo!$BK$3:AAC$3,0)),"")),IF($BA96="Other",(IFERROR(INDEX(NewOther!$BK79:AAC79,1,MATCH(GH$2,NewOther!$BK$3:AAC$3,0)),""))))))
)
THANKS!!!
This is based on a purely textual analysis of your formula, since data required for a meaningful analysis hasn't been forthcoming:
the expression below occurs 4 times in your formula
IFERROR(INDEX(namesemi,1,MATCH(GH$2,semidate,0)),"")
as does this one
IFERROR(INDEX(namemonthly,1,MATCH(GH$2,mothlydate,0))
which means that, in the worst-case circumstances, one or both expressions are being evaluated on FOUR separate occasions - it would be sensible to consider making one or both of these named 'values' at the start of the LET() function, such that, in the worst-case cirumstances going forward, each would be evaluated only once.

generate all possibilities from two fixed rows of entries?

I spent hours trying to look for a solution and I feel like I got close but figured asking would be the best way.
Lets say I have a table with 2 columns, column A is an item, and column B is a price for the item. This table has 12 entries. What I would like to do is generate additional tables of 6 entries that do not exceed a certain price. see below for example. The number i want these table to not exceed is 50,000.
for example the first entry could be an apple at 9,000 value. the apple is column a, and value column b.
Can someone help with a way to generate all combinations of 6 items from column a, that do not exceed a combined price of 50,000 in column b?
With 12 items you have 212-1 or 4095 possible combinations of products. These can map into the 12 bits of a 12-bit binary number. It is not difficult to write a macro to calculate the total cost of each combination and then filter the result to display results less than or equal to 50,000.
EDIT#1:
Please see:
Best possible combination sum of predefined numbers that smaller or equal NN
Listing all possible combination without repetition,VBA

Vlookup duplicates + IF to return a value

I have 2 columns I am trying to populate in my sheet using vlookup. One column is the buy amount and one is the sell amount. I am using 1 unique ID to lookup into my lookup file.
However the data I am looking up has duplicate IDs, with a measure name in one column and the value in another column. The values are showing twice due to buy and sell amount names.
Looks something like this:
ID Measure Name Measure value
1 Buy 1000
1 Sell 2000
2 Buy 5000
2 Sell 10000
How can I vlookup both and populate both to my sheet like this:
ID Buy Amount Sell Amount
1 1000 2000
2 5000 10000
I got this:
=IF(VLOOKUP(A2,valumeasure3!C:U, COLUMNS(C:U),FALSE),valumeasure3!E:E,0)
Not sure where to go from here, or if vlookup is even feasible.
As #ScottCraner mentioned, SUMIFS is the way to go here.
Applied to your specific situation, your formula should be this for the Buy value:
=SUMIFS(valumeasure3!$E:$E,valumeasure3!$C:$C,$A2,valumeasure3!$D:$D,"Buy")
And the for the Sell value:
=SUMIFS(valumeasure3!$E:$E,valumeasure3!$C:$C,$A2,valumeasure3!$D:$D,"Sell")

finding the closest match based on multiple criteria

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.

Resources