Is there a way to return a cell value if two arrays associated with that value are equal? - arrays

I have a data set that details out specific discounts based on a store number, that data set looks similar to this:
My two questions are:
Is there a way to pull out the unique arrays within the data set using formulas? (The arrays are a set size of columns and rows within the data set)
Is there a way to get a unique list of stores that fit the criteria of each unique array?
In this example I am trying to get something like this to return:
I've been able to build a workaround by assigning specific areas of the worksheet as Array1, Array2, etc. and then using a formula to check if the individual arrays for each store are equal but I'm looking for a quicker way to easily pull out the unique arrays and associated stores.

Related

Can I make an array out of a range of countif functions?

A truncated version of my data is in the form shown in the screenshot below: three columns of 5 unique names. The names appear in any order and in any position but never repeat in a single row.
My goal is to create an array that contains the number of times Adam appears in each row. I can fill down the formula=countif(A2:C2,$I$2) in a new column, or if I write the array manually for each row, it looks like:
={countif(A2:C2,$I$2);countif(A3:C3,$I$2);countif(A4:C4,$I$2);countif(A5:C5,$I$2);countif(A6:C6,$I$2)}
Where cell I2 contains "Adam". Of course, this is not feasible for large data sets.
I know that arrays are effectively cells turned into ranges, but my main issue is that the cell I'm trying to transform already references a range, and I don't know how to tell the software to apply the countif down each row (i.e. I intuitively would like to do something like countif((A2:C2):(A99:C99),"Adam") but understand that's not how spreadsheets work).
My goal is ultimately to perform some operations on the corresponding array but I think I'm comfortable enough with that once I can get the array formula I'm looking for.
try:
=ARRAYFORMULA(IF(A2:A="",,MMULT(IF(A2:C="Adam", 1, 0), {1;1;1})))

Can't query semi-structured data using lateral flatten etc

I've got some data in a table, and one of the columns is a Variant which contains a ree of JSON data. I can successfully flatten arrays, and arrays within arrays to access data therein but I'm struggling with flattening key-value pairs to access the value for a given key.
I've seen the docs at https://docs.snowflake.net/manuals/user-guide/json-basics-tutorial.html mapping this onto my use case results in NULL values in the results.
My variant is show in part below - In particular it's values like MatchStatus and the key/values under Variables that I'm interested in extracting.
Thanks for any helpful suggestions.
The described JSON has a simple path-like structure with objects at various levels (and no arrays).
Per Snowflake's semi-structured data documentation, use the dot notation to extract a value following a (flatly nested) path:
Insert a colon : between the VARIANT column name
and any first-level element: <column>:<level1_element>.
Use dot notation to traverse a path in a JSON object:
<column>:<level1_element>.<level2_element>.<level3_element>.
An example would be (note the chained use of dots in the third and fourth lines):
SELECT
badminton_odds:Id as id,
badminton_odds:PricingRequest.MatchStatus as match_status,
badminton_odds:PricingRequest.Variables.Dispersion as var_dispersion
FROM odds_table
You do not require FLATTEN for simple, singular value extraction. Use FLATTEN when you have a need to explode some series data into multiple rows (such as in case of arrays).
For example, if the described JSON in the question is how a single array element looks in a long array of such objects, you may use FLATTEN to first break the whole array into rows, and then apply path style extraction to retrieve the value from each row.

formula to generate array with variables such as =B1/B2, etc

How does one generate an array whose elements are cell values or math operation of cell values? For example, how does one generate an array of {0,1,A1,B1}) or {8,3,A1/B1,A1*B1} or {0,1,A1/B1-2, A1*B1+3}?
I have not found anything on the net regarding this topic.

Using Index/Max/If to find multiple values in array and get for highest corresponding value result displayed

I am currently trying to use some excel formulas like "Index"/"Max"/"If" with multiple criteria. This means I want to lookup all values in A2:I2 and search them in my second table in A8:A20. At the same time I want to lookup the maximum in C8:C20 and for the entry that
1) matches A2:A20 and 2) has the highest value in C2:C20 I want to get the value of the "Result" column be displayed in I7, which is "D".
After trying multiple variations with Index/Vlookup/Max/If etc. I cannot find any formula for this problem to handle multiple matching criteria within arrays.
Perhaps is there any VBA solution to loop through both tables and get the result displayed below?
P.S. As this is only a small part of my worksheet it is not efficient to use one Index formula for each cell trying to match my second table. It would be great to work with two arrays matching each others values.
Using your provided sample, in result cell I7 use this formula: =MAX(INDEX((A8:A20=A2:I2)*C8:C20,))

Use set of keywords to extract values from second worksheet

I'll try to explain the problem I'm facing best as I can.
A have a set of data that contains multiple duplicates extracted as an excel file. Within this data are "keys" that I want to use to filter out relevant data from another workbook.
I start by removing duplicates from the list of keywords and I think I got this working kind of satisfactory. I then try to extract and calculate the minimum from the values using the following array formula:
=MIN(VLOOKUP(Blad1!D2:D8,Blad2!A3:D9,2))
However, this doesn't work as expected. The value returns the minimum value from the target range, but seems to ignore the provided keywords. Instead it simply finds the minimum value of the entire range.
I am far from a professional when it comes to excel so any suggestions on how this could be done in a more efficient way are welcome.
Here is a link to a sample document.
These array formulas should be what you need.
'MINIF in F2,
=MIN(IF(COUNTIF($D$2:$D$8, Blad2!$A$2:$A$9&""), Blad2!$B$2:$B$9))
'MAXIF in G2
=MAX(IF(COUNTIF($D$2:$D$8, Blad2!$A$2:$A$9&""), Blad2!$C$2:$C$9))
'AVERAGEIF¹ in H2
=AVERAGE(IF(COUNTIF($D$2:$D$8, Blad2!$A$2:$A$9&""), Blad2!$D$2:$D$9))
Array formulas need to be finalized with Ctrl+Shift+Enter↵.
Try and reduce your full-column references to ranges more closely representing the extents of your actual data. Array formulas chew up calculation cycles logarithmically so it is good practise to narrow the referenced ranges to a minimum.
The results are 15, 35 and 23.6.
¹Note that this is NOT the native AVERAGEIF function or AVERAGEIFS function but an array formula. This approach was chosen due to the large number of criteria.

Resources