List Comprehensions in the Grid
This example workbook demonstrates how the Resolver One formulae language supports truly Pythonic techniques like list comprehensions.
You will learn...
- How to use list comprehensions in the Resolver One grid.
Before you begin
Do one of the following to open the example workbook:
- In Windows, select Start, Resolver One, Samples, Simple functions and formatting.
- Download the file from the Resolver Exchange.
Exercise
We're going to put a list comprehension in cell D10 that will pick out all of the goods that cost less than 15:
Select the whole range of data, from A1 to C8.
Select Data, Edit Names.
Click New.
In the name column enter 'stockData'.
Click OK.
In cell D10, enter the following Python-based formula:
=[row["Goods"] for row in stockData.Rows if row["Gross Price"] < 15]
The items are displayed.
Going further
Now, if you want, you can put other Pythonic formulae in other cells to, say, index into this list to find its length.
For example...
- Put =D10[2] in D11, and you will get the third item (watch that zero-based indexing!).
- Put =len(D10) in D12 to get its length.
Comments
If you have comments, questions or suggestions about any of the Resolver One documentation, please post them to the Documentation Suggestions Forum.
