Manage data in a Project Siena gallery
After you put a set of data into a gallery in Project Siena, you can filter that data, sort it, save selected items to separate list, and perform other tasks that help you get the most from your data. For a general overview of Project Siena and links to resources such as sample apps, video tutorials, and forums, see Project Siena.
Examples in this procedure use this data source, named RevenueLedger:
Product |
Year |
Revenue |
---|---|---|
Bongos |
2012 |
$14,000 |
Trombones |
2012 |
$15,000 |
Trombones |
2013 |
$17,000 |
Bongos |
2013 |
$19,000 |
Trombones |
2014 |
$21,000 |
Violins |
2012 |
$21,000 |
Bongos |
2014 |
$23,000 |
Violins |
2013 |
$26,000 |
Violins |
2014 |
$28,000 |
Prerequisites
Project Siena, which you can get for free from the Windows Store
You can find system requirements and other information in the release notes.
Familiarity with basic operations in Project Siena, as Create your first app with Project Siena describes.
Filter a gallery
Import data or create a collection, and then create a custom gallery that shows your data source.
Add a Radio, Listbox, or Drop-Down control, and set its Items property to a function that follows this syntax:
Distinct(DataSourceName, ColumnName)
For example, you could use this function to show the name of each Product in the RevenueLedger data source only once, even though those names appear multiple times in the original data source:
Distinct(RevenueLedger, Product)
Set the Items property of the gallery to a function that follows this syntax:
Filter(DataSourceName,ColumnName = RadioControlName1!Selected!Value)
For example, you could use this function to show only those rows in the RevenueLedger data source that contain information about the product chosen in a control named FilterCriteria:
Filter(RevenueLedger, Product = FilterCriteria!Selected!Value)
Click an option in the list to show only those rows that match your criteria.
(optional) Filter by multiple criteria:
Add another Radio control, and set its Items property to a function that follows the same syntax as the Items property for the other list.
Set the Items property of the gallery to a function that follows this syntax:
Filter(DataSourceName, ColumnName = RadioControlName1!Selected!Result && RadioControlName2!Selected!Result)
(optional) Filter by partial-match text from the user:
Add an input-text control, and change the Items property of the gallery to a function that follows this syntax:
Filter(DataSourceName, InputControlName!Text in ColumnName)
For example, you could use this function to show only those rows in the RevenueLedger data source in which the values in the Product column contain the string in the FilterCriteria box:
Filter(RevenueLedger, FilterCriteria!Text in Product)
Sort a gallery
Import data or create a collection, and then create a custom gallery that shows your data source.
Examples in this procedure use this data source, named RevenueLedger:
Product
Year
Revenue
Bongos
2012
$14,000
Trombones
2012
$15,000
Trombones
2013
$17,000
Bongos
2013
$19,000
Trombones
2014
$21,000
Violins
2012
$21,000
Bongos
2014
$23,000
Violins
2013
$26,000
Violins
2014
$28,000
Change the Items property of the gallery to a function that follows this syntax:
Sort(DataSourceName, ColumnName)
By default, the function sorts data in ascending order, but you can add a parameter to sort the data in descending order. For example, you could use this function to sort the RevenueLedger data source so that values in the Revenue column appeared in descending order:
Sort(RevenueLedger, Revenue, SortOrder!Descending)
Show a selection in a gallery
Import data or create a collection, and then create a custom gallery to show your data.
Click the label in the upper-left corner of the gallery, press Alt-V, click Shapes in the list that appears, and then click Rectangle.
In the Design category, set the properties of the rectangle to these values:
Fill: RGBA(0, 0, 0, 0)
Border Style: BorderStyle!Solid
Border Thickness: 2
Border Color: RGBA(192, 0, 0, 1)
Move the rectangle toward the left edge of the gallery, and resize the rectangle so it fits around each item in the gallery.
With the rectangle still selected, click Options near the bottom of the window, and then click the Visible icon (on the left side, near the bottom of the dialog box that appears).
In the text box, type the following function:
If(ThisItem!IsSelected, true, false)
Press F5, click any item in the gallery, and then click another.
The red rectangle appears only around the item that you clicked most recently.
Press Esc to return to the design workspace.