...
The following code sample displays to the end user a clickable 'Generic filter' link, which opens a FilterBuilder window.
Paste code macro | ||
---|---|---|
| ||
def dmCtx = api.getDatamartContext() // without initial filter: def filter = api.datamartFilterBuilderUserEntry("Filter", "Transaction DM") def filter = api.datamartFilterBuilderUserEntry("Filter", "Transaction DM", Filter.equal("InvoiceDateYear", "2015")) api.trace("Filter", null, filter) def dm = dmCtx.getDatamart("Transaction DM") def q = dmCtx.newQuery(dm) q.select("Country") q.select("CustomerID") q.select("ProductID") q.select("SUM(InvoicePrice)", "Revenue") q.select("SUM(Quantity)", "Volume") q.where(filter) api.trace("Query", null, q) def result = dmCtx.executeQuery(q) api.trace("Data", null, result?.data) return result |
...
The following sample shows 2 dim filters (without default values) to the end user.
The (optional) underlying generic filter (country == Italy) is hidden and not modifiable by the user.
Note that the dim filter fields are in a sub-section with the user entry's name as the title.
Paste code macro | ||
---|---|---|
| ||
def dmCtx = api.getDatamartContext() def dimFilters =["CustomerID", "ProductID"] def filter = api.datamartFilterBuilderUserEntry("Italy", "Transaction DM", dimFilters, Filter.equal("Country", "Italy")) api.trace("Filter", null, filter) def dm = dmCtx.getDatamart("Transaction DM") def q = dmCtx.newQuery(dm) q.select("Country") q.select("CustomerID") q.select("ProductID") q.select("SUM(InvoicePrice)", "Revenue") q.select("SUM(Quantity)", "Volume") q.where(filter) api.trace("Query", null, q) def result = dmCtx.executeQuery(q) api.trace("Data", null, result?.data) return result |
...
The following sample shows two dim filters with default values (CD-00155, MB-0005) to the end user.
The (optional) underlying generic filter (country == Germany) is hidden and not modifiable by the user (do not confuse with the section title, which is taken from the user entry name)..
Paste code macro | ||
---|---|---|
| ||
def dmCtx = api.getDatamartContext() def dimFilters =["CustomerID":"CD-00155", "ProductID":"MB-0005"] def filter = api.datamartFilterBuilderUserEntry("Germany", "Transaction DM", dimFilters, Filter.equal("Country", "Germany")) api.trace("Filter", null, filter) def dm = dmCtx.getDatamart("Transaction DM") def q = dmCtx.newQuery(dm) q.select("Country") q.select("CustomerID") q.select("ProductID") q.select("SUM(InvoicePrice)", "Revenue") q.select("SUM(Quantity)", "Volume") q.where(filter) api.trace("Query", null, q) def result = dmCtx.executeQuery(q) api.trace("Data", null, result?.data) return result |
...