Querying Specific Scenarios
A visual is created off query data. If a query is set to fetch all the data from all the completed scenarios then it will display all of the data from all of the completed scenarios. But queries can also be setup to only draw data from specific scenarios. Filters and parameters can be set to either look for results from a specific scenario or a group of scenarios. All this can be done in the Source Code section of the query page. The Source Code section can be access by clicking on Edit Source near the top right of the screen.
The source editor will then switch with the data viewer and the query page will now look like the screen shot below.
Users should always fork the main query created by Akumen before they make any changes to the source code. To fork your query click on the three dots next to the Edit Source button and select fork from the popup menu.
Within the Source Editor users can change the way and type of data is pulled into the query for analysis. In this source editor the schema browser will list all of the different tables within Redash. If clicked on they will expand to show all of the columns in the table. These columns and tables can be inserted into the source code by clicking on the double arrows next to the name.
Clicking on the arrows by the name will insert the name into the code editor of the source editor page. However, it will only insert the name exactly as it appears in the list. Users will still need to enter code statements before or after the name of the column or table.
As mentioned at the beginning of this page, while users are in the source code they are able to modify the code to filter queries for results which in turn can create visualizations that only show the filtered values. Filters are enabled by following a naming convention for columns.
If you want to focus on a specific value, you will need to alias your column to <columnName>::filter
. So where in your source code it says the following:
AS "Study/Scenario::multi-filter"
you will want to change the Study/Scenario to the name of your column followed by filter.
Akumen by default already filters your data as a multi-filter.
Redash also supports parameters, which allow users to insert values at run time without editing your base query. You can edit your base query if you want to specify values by using a WHERE clause (or filter block in NoSQL) to suit the present need, but if the value changes or the query needs to be changed because of a scenario name change then the source code will need to be edited. To use a query parameter use {{}}.
For more information on filters and codes that can be used to filter data click here. For more information about parameters, how they work click here. Both of these Redash pages will explain how to use filters and parameters within queries. For a worked example on editing source code click here. This link will take you to the reports section of our Coffee Shop tutorial where static charts are created to map certain scenarios.