0

I'm working with a big dataset with many types of products to be uploaded to Shopify In order for the correct dropdown(s) to be displayed, I have to let Shopify know what the "children" (variant) items are different for. In the case of apples in this screenshot, the color is a differentiator and in the case of oranges is the size. I'm stuck on how to formulate this problem and I've been stuck before in the same situation (a similar problem where I need to see the differences only in a big data set) So maybe you can help :)

screenshot of the excel

2 Answers 2

0

Test which array has the most Unique values and return that array:

=LET(a,UNIQUE(FILTER(fruits[Color],fruits[Fruit]=fruits[@Fruit],"")),b,UNIQUE(FILTER(fruits[Size],fruits[Fruit]=fruits[@Fruit],"")),TRANSPOSE(IF(IF(a="",0,COUNTA(a))>IF(b="",0,COUNTA(b)),a,b)))

enter image description here

1
  • Thank you so much. I think I found a bug in excel's Unique, or is it the "Let's" bug, or my brain's bug :) All I did is flipped your ">" to "<=" and for some reason, the Unique doesn't work and I get big big big 3? times instead of 1 for some reason I'm doing it with "<", then with ">" living some space not to spill, then "adding/joining" two arrays with the help of texjoin and cutting with filterxml to a longer joined array. curious if there is a more elegant way of doing that? Thanks again
    – Aram
    Commented May 10, 2022 at 20:10
0

You've got a Table for the data set, so make another Table (or just a range, but it looks like you like and/or are comfortable with Tables) for the list of fruits and the differentiator (column in the data set Table) to use for each. Perhaps you do that in E1:F3.

Then build the output table: not a Table, but just a regular range. Perhaps it will start in H1. Label that "Fruit", and move on to labelling the next ten, say, columns with this formula:

="Diff-"&(COLUMN()-8)

or whatever seems like good column headings for the differentiators for the fruits.

Why a normal range and not a Table? Because a Table will NOT allow a SPILL formula inside it to work. And you'd like to have that feature. (It is not because the column headings would convert to text... that wouldn't be any unhappy thing at all.)

In H2, place this formula for listing all the unique items in the data set's "Fruit" column:

=UNIQUE(INDIRECT("Table1["&H1&"]"))

or, you know, don't connect it like that to H1, just use the direct:

=UNIQUE(Table1[Fruit])

So now you have suitable headings and a column collecting all the fruit names that exist in the data set "Fruit" column... the set of unique names, not all the entries. All you need now is their unique existing differentiators.

=TRANSPOSE(UNIQUE(INDEX(FILTER(Table1[[Color]:[Size]],Table1[Fruit]=H2),,MATCH(XLOOKUP(H2,Table2[Fruit],Table2[Differentiator]),Table1[[#Headers],[Color]:[Size]],0))))

XLOOKUP(H2,Table2[Fruit],Table2[Differentiator]) uses the value in column H to lookup the fruit's differentiator in the second Table. It passes that value to the MATCH() function wrapping it which compares it to the headers of the data set Table and returns a number that you will use as a column number in the eventual INDEX() function.

For that INDEX() function you want all the otherwise acceptable rows to be used hence the empty commas that would usually have a row number between them.

INDEX() needs a data set to work with and that's what FILTER() does for you. Its test looks for the fruit in H2 in the data set Table and returns those rows that match the fruit. But it returns all the characteristics columns (two here, but you could expand it to more someday).

INDEX() then uses the column number found by MATCH() to return only one characteristics column to the formula.

Now that you have only the right column and only the rows in it that are for the fruit in H2, you can put UNIQUE() to work.

It will return a column of the unique values you need. But you need a row, so the TRANSPOSE() function finishes things off for you.

SPILL fills the row for you. Copy down as required.

Then collect the output data in whatever way you need (copy and paste in some other program ("Shopify" directly, perhaps), paste into a transfer spreadsheet you save as a CSV file, or perhaps a spreadsheet works, however you go about it. SPILL arrays copy and paste nicely.

Then when you have time, dress it up with LET(), giving the horrid "Table1[[Color]" references real readable names, and placing the input that you might wish to edit, like "H2" at the absolute start so they are easy to find and edit.

Finally, when setting up the T/tables, consider separating them, perhaps onto different sheets, to allow easy expansion of them as you add more kinds of items over time.

1
  • Thank you very much for such a detailed answer and an effort put to explain in detail, I really appreciate it. I've tried to replicate it, but, unless I'm missing something, it seems that you want me to fill the "differentiator" (in F2, F3) manually as an input for the formulas. My goal is to find those differentiators. Sorry if I was not clear in the beginning, in my example it's visible that apples differ by color and oranges by color and the size. But it is not visible in my real data, and finding differentiators from the dataset is my original goal. Please let me know if I miss something
    – Aram
    Commented May 11, 2022 at 15:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .