Forum Discussion
Any to any comparison in excel
- Nov 07, 2023
samery Are you using Excel for MS365? If so, here's a couple of recursive formulas you could try. However, they will only return the most optimized combination of vendors...
To return a summary of the optimal combination of vendors with their total items covered, try the following formula in any cell (with nothing below it):
=LET( F, LAMBDA(X,head,data,val, LET( a, BYCOL(data, LAMBDA(col, SUM(col))), b, MAX(a), c, XMATCH(b, a), IF(b=0, val, X(X, head, FILTER(data, INDEX(data,, c)=0, 0), VSTACK(val, HSTACK(INDEX(head, c), b)))))), F(F, C1:Q1, C2:Q231, {"Company","Total Covered"}))With your current data, the results should look something like this:
Company Total Covered S&P 138 Oxford eco0mics 28 ECONDB 20 Kpler 11 blue water 5 alphaliner 2 economist intelligence 2 Sinay 1 Oxford Analytica 1 TDM 1 To return a detailed list of the optimal combination of vendors with all of their items covered, try the following formula in any cell (will nothing below it):
=LET( F, LAMBDA(X,head,data,val, LET( a, BYCOL(data, LAMBDA(col, SUM(col))), b, MAX(a), c, XMATCH(b, a), d, INDEX(head, c), IF(b=0, val, X(X, head, FILTER(data, INDEX(data,, c)=0, 0), VSTACK(val, IFNA(HSTACK(d, FILTER(TAKE(data,, 1), INDEX(data,, c)=1)), d)))))), F(F, B1:Q1, B2:Q231, {"Company","Items Covered"}))Finally, to return a list of all items not covered by any vendor, try the following formula in any cell (with nothing below it):
=LET( data, B2:Q231, qty, BYROW(data, LAMBDA(r, SUM(r))), VSTACK("Items Not Covered", FILTER(TAKE(data,, 1), qty=0, "none")))It's a start, anyways. I'll think about it some more and try to find a way to generate other combinations of vendors.
You are right probably, I am complicating things.
Please redownload the file again and go to cell B235. The idea is to show what every vendor can provide and then the extra variables that the next vendor can provide above and beyond the variables provided by the previous providers. IS this now clear?
samery Are you using Excel for MS365? If so, here's a couple of recursive formulas you could try. However, they will only return the most optimized combination of vendors...
To return a summary of the optimal combination of vendors with their total items covered, try the following formula in any cell (with nothing below it):
=LET(
F, LAMBDA(X,head,data,val, LET(
a, BYCOL(data, LAMBDA(col, SUM(col))),
b, MAX(a),
c, XMATCH(b, a),
IF(b=0, val, X(X, head, FILTER(data, INDEX(data,, c)=0, 0),
VSTACK(val, HSTACK(INDEX(head, c), b)))))),
F(F, C1:Q1, C2:Q231, {"Company","Total Covered"}))
With your current data, the results should look something like this:
| Company | Total Covered |
| S&P | 138 |
| Oxford eco0mics | 28 |
| ECONDB | 20 |
| Kpler | 11 |
| blue water | 5 |
| alphaliner | 2 |
| economist intelligence | 2 |
| Sinay | 1 |
| Oxford Analytica | 1 |
| TDM | 1 |
To return a detailed list of the optimal combination of vendors with all of their items covered, try the following formula in any cell (will nothing below it):
=LET(
F, LAMBDA(X,head,data,val, LET(
a, BYCOL(data, LAMBDA(col, SUM(col))),
b, MAX(a),
c, XMATCH(b, a),
d, INDEX(head, c),
IF(b=0, val, X(X, head, FILTER(data, INDEX(data,, c)=0, 0),
VSTACK(val, IFNA(HSTACK(d, FILTER(TAKE(data,, 1), INDEX(data,, c)=1)), d)))))),
F(F, B1:Q1, B2:Q231, {"Company","Items Covered"}))
Finally, to return a list of all items not covered by any vendor, try the following formula in any cell (with nothing below it):
=LET(
data, B2:Q231,
qty, BYROW(data, LAMBDA(r, SUM(r))),
VSTACK("Items Not Covered", FILTER(TAKE(data,, 1), qty=0, "none")))
It's a start, anyways. I'll think about it some more and try to find a way to generate other combinations of vendors.
- sameryNov 09, 2023Copper Contributorhi djclements
I think the addition of up to 5 is more then what I expected. There was few variables that have bad coverage so to speak so I wanted to show the client that from a formula standpoint, that's how variables are distributed but client to decide which coverage to consider or not. Warm thanks.
The totals I mentioned are exactly what you presented: how much client offers vs how much client needs.
I think the work is amazing and I am really and obsoletely thankful. - djclementsNov 08, 2023Silver Contributor
samery Please see the newly attached workbook (Book3.xlsx). I moved all of the custom functions to Name Manager and added the ability for you to manually select multiple vendors (up to 5). They will be prioritized in the order you choose, then all subsequent vendors will automatically be filled based on the number of remaining items they can cover.
In order to get the Refresh and Scope variables to pull in, I had to modify the headers slightly on the RawData sheet... all merged headers were unmerged and repeated across their applicable columns. I also verified the Target Data labels on Sheet1 were identical to those on the RawData sheet. All headers and labels must match in order to pull in the additional information.
I wasn't exactly sure what you wanted the Full Coverage column to do, so I set it up to pull the values from the total row on Sheet1 for each vendor in the list. If that's not what you wanted, please try to explain it again.
- sameryNov 08, 2023Copper Contributor
hi again
I promise I will leave you alone after this last post so please bear with me.
you noticed I hinted earlier some other complications related to variables such as refresh rate and scope.
I tried to adjust your great work all by myself but I didnt know how to do it.
First: Please check the attached book2.xls, tab Raw data, it has the actual replica of what I have along with 2 other descriptive fields for every variable: the refresh rate and the scope. I know that this data is not available for all variables.
Second: now please go back to the 2nd tab you created, basically I am supposed to add couple of more fields for every data from the raw data tab so that the client would know what exactly he is buying. Obviously, I should pickup the refresh rate and the scope of the relevant vendor.
Such information should help my client to decide whether or not to buy a particular variable form Vendor X for example if the scope is weak. I also added another simple sum small column next to the nice table you put on the top left on coverage only so that the client will visually see how much before and after, meaning how much client should consumer form vendor vs how much vendor is proving as a simple sum.
do you think you can help me with that as well?
many thanks in advance.
Regards
Samer.
- sameryNov 08, 2023Copper ContributorYour work is amazing, neat, clear and straight forward. It answers exactly what the client wants to see. Thank you so much
- djclementsNov 08, 2023Silver Contributor
samery Please see the attached workbook (Book2.xlsx). Sheet2 is setup for you to select the first vendor to start with, then the formulas will generate the optimal combination of additional vendors thereafter.
I've also completed the summary you were aiming for on Sheet1, but it's not an optimized summary, as it just goes through the list of vendors in the order that they appear (not by the number of items they cover).
Also worth noting, the number of possible combinations with 15 different vendors is 15! = 1,307,674,368,000. So, the prospect of getting all possible combinations is not very realistic. I think the best combination of results are demonstrated on Sheet2, although they are still weighted by the next vendor with the maximum number of items remaining. Perhaps there could be a way to weight them by other factors, but I would need to see what those factors are.
Hopefully the attached workbook will provide you with enough scenarios. Cheers!
- sameryNov 08, 2023Copper Contributor
just a question please:
in this formula:
=LET(
F, LAMBDA(X,head,data,val, LET(
a, BYCOL(data, LAMBDA(col, SUM(col))),
b, MAX(a),
c, XMATCH(b, a),
IF(b=0, val, X(X, head, FILTER(data, INDEX(data,, c)=0, 0),
VSTACK(val, HSTACK(INDEX(head, c), b)))))),
F(F, C1:Q1, C2:Q231, {"Company","Total Covered"}))
The result indicates that S&P should be the lead which is obvious then all the other vendors were added very nicely depending on the extra variables that they provide on top of the previous one. This is what the client wants which is great. But it assumes all variables have equal weighting. Client is saying what if vendor X say Factset which has the least number of variables but nonetheless carries better coverage. So client says what if we trigger another scenario by starting not with a top vendor rather any other vendor as the start then align all the other vendors cumulatively till we close as much as possible the remaining variables.
Now from a sorting standpoint, the result is the same but from a variable importance standpoint the client is insisting on having visibility on all scenarios and then he can conclude depending on other factors (such as coverage, weight, refresh rate,.... and many other stuff which are not mentioned to avoid complication).
So may I ask you the following:
How can please revise your formula to rerun the same logic on each and every vendor (clearly in different tables)? in other words, can your formula be reprogrammed to start with a vendor not as the top in terms of number of variables but as a variable in a cell then a formula would work its way towards the other vendors to add remaining vendors?