Monday, 27 January 2025

even more dynamic array examples

 Here are 3 alternative examples for each of the 20 dynamic array functions mentioned earlier. These examples will help you understand the flexibility and power of these functions in different scenarios.


1. SORT Function

Example 1: Sort in descending order

Data:

AB
10X
30Y
20Z

Formula:

excel
Copy
=SORT(A1:B3, 1, -1)

Result:
| 30 | Y |
| 20 | Z |
| 10 | X |


Example 2: Sort by the second column

Data:

AB
10Z
30X
20Y

Formula:

excel
Copy
=SORT(A1:B3, 2, 1)

Result:
| 30 | X |
| 20 | Y |
| 10 | Z |


Example 3: Sort with multiple columns

Data:

AB
10Z
20Y
10X

Formula:

excel
Copy
=SORT(A1:B3, {1, 2}, {1, 1})

Result:
| 10 | X |
| 10 | Z |
| 20 | Y |


2. SORTBY Function

Example 1: Sort by a different range

Data:

AB
10X
30Y
20Z

Formula:

excel
Copy
=SORTBY(A1:B3, B1:B3, -1)

Result:
| 20 | Z |
| 30 | Y |
| 10 | X |


Example 2: Sort by multiple columns

Data:

AB
10Z
20Y
10X

Formula:

excel
Copy
=SORTBY(A1:B3, A1:A3, 1, B1:B3, -1)

Result:
| 10 | Z |
| 10 | X |
| 20 | Y |


Example 3: Sort by a calculated column

Data:

AB
102
301
203

Formula:

excel
Copy
=SORTBY(A1:B3, A1:A3 * B1:B3, -1)

Result:
| 30 | 1 |
| 20 | 3 |
| 10 | 2 |


3. FILTER Function

Example 1: Filter with text criteria

Data:

AB
Apple10
Banana20
Cherry30

Formula:

excel
Copy
=FILTER(A1:B3, A1:A3 = "Banana")

Result:
| Banana | 20 |


Example 2: Filter with multiple conditions

Data:

AB
10X
30Y
20Z

Formula:

excel
Copy
=FILTER(A1:B3, (A1:A3 > 15) * (B1:B3 = "Y"))

Result:
| 30 | Y |


Example 3: Filter with OR logic

Data:

AB
10X
30Y
20Z

Formula:

excel
Copy
=FILTER(A1:B3, (A1:A3 = 10) + (B1:B3 = "Z"))

Result:
| 10 | X |
| 20 | Z |


4. UNIQUE Function

Example 1: Unique values from a single column

Data:

A
10
20
10
30

Formula:

excel
Copy
=UNIQUE(A1:A4)

Result:
| 10 |
| 20 |
| 30 |


Example 2: Unique rows from a table

Data:

AB
10X
20Y
10X
30Z

Formula:

excel
Copy
=UNIQUE(A1:B4)

Result:
| 10 | X |
| 20 | Y |
| 30 | Z |


Example 3: Unique values with case sensitivity

Data:

A
Apple
apple
Banana

Formula:

excel
Copy
=UNIQUE(A1:A3, TRUE)

Result:
| Apple |
| apple |
| Banana|


5. SEQUENCE Function

Example 1: Generate a 3x3 matrix

Formula:

excel
Copy
=SEQUENCE(3, 3)

Result:
| 1 | 2 | 3 |
| 4 | 5 | 6 |
| 7 | 8 | 9 |


Example 2: Generate a sequence of even numbers

Formula:

excel
Copy
=SEQUENCE(5, 1, 2, 2)

Result:
| 2 |
| 4 |
| 6 |
| 8 |
| 10 |


Example 3: Generate a sequence of dates

Formula:

excel
Copy
=SEQUENCE(5, 1, DATE(2023, 10, 1), 1)

Result:
| 10/1/2023 |
| 10/2/2023 |
| 10/3/2023 |
| 10/4/2023 |
| 10/5/2023 |


6. RANDARRAY Function

Example 1: Generate random decimals

Formula:

excel
Copy
=RANDARRAY(3, 2)

Result:
| 0.12 | 0.45 |
| 0.67 | 0.89 |
| 0.34 | 0.56 |


Example 2: Generate random integers between 1 and 100

Formula:

excel
Copy
=RANDARRAY(3, 2, 1, 100, TRUE)

Result:
| 45 | 67 |
| 12 | 89 |
| 34 | 56 |


Example 3: Generate a single random number

Formula:

excel
Copy
=RANDARRAY(1, 1)

Result:
| 0.78 |


7. XLOOKUP Function

Example 1: Lookup with exact match

Data:

AB
Apple10
Banana20
Cherry30

Formula:

excel
Copy
=XLOOKUP("Banana", A1:A3, B1:B3)

Result:
| 20 |


Example 2: Lookup with approximate match

Data:

AB
10X
20Y
30Z

Formula:

excel
Copy
=XLOOKUP(25, A1:A3, B1:B3, , -1)

Result:
| Y |


Example 3: Lookup with wildcard

Data:

AB
Apple10
Banana20
Cherry30

Formula:

excel
Copy
=XLOOKUP("Ban*", A1:A3, B1:B3)

Result:
| 20 |


Let me know if you'd like more example

No comments:

Post a Comment