Visual SQL Actions allow you to perform a variety of post-query manipulations in Chartio. Actions can be added to the Pipeline under the initial Query to edit that query’s results.
There are two sets of Actions:
- Table Actions are the set of Actions that affect the entire Result Table and are found directly above the Result Table
Column Actions are the set of Actions that affect a single column and are found in each column’s Column Actions menu – the dropdown to the right of the column name in the Result Table
Note: The Column Actions menu only appears after you click Run Query for your initial Query.
Keyboard shortcuts! For all Actions (except Add Query and Filter), you can submit their forms by pressing
|Table Actions||Column Actions|
|Add Query||Rename Column|
|Calculated Column||Sort Rows|
|Reorder Columns||Move to Start/End|
Before you can show your data in a chart, you need to get some data to show. This is why every chart must start with an initial Query. To help you remember this requirement, new charts have a Query Action added by default.
The Query is a major part of Visual SQL, so we gave it a dedicated page. Check out how to Start a Query to learn more about the Query Action.
Once you’ve executed your initial Query, you can add a new Query by clicking Add Query above the Result Table.
Merge the result sets of two Queries by joining them together. You can’t manually add a Join Action to the Pipeline; it only appears in the Pipeline after you’ve merged a second Query (See Merging Queries to learn more). You can choose a different join type and–depending on the chosen join type–choose how many columns to join by and whether to include or exclude certain types of data from the merged result set.
- You can select the number of columns to join by for Outer, Inner, and Left Joins.
- For Outer Joins, you can choose whether to include or exclude NULL match rows.
- For Unions, you can choose whether to include or exclude duplicate rows by choosing either all or distinct values. If you choose to include or exclude query names, a column titled Layer will be added to your result set; it labels each row with the Query that it came from.
Add a Calculated Column to your query results. Use one of our Guided Formulas or a Custom Formula to manipulate or add data.
Filter rows on certain conditions. Choose to include or exclude rows matching any or all specified filter conditions.
- Matching all conditions
Uses AND logic. Row will be included or excluded only if it matches every condition.
- Matching any conditions
Uses OR logic. Row will be included or excluded if it matches one or more conditions.
Unlike the filters in a Query Action, you can only filter by columns in your result set.
Multiple Filter Actions in the Pipeline are connected by an implicit
AND operator. With this, you can create a chain of
OR filter conditions.
If you need more help, check out our OR filter examples.
Regular expression matching
Any text column supports filtering by Java-style regular expressions in the Filter Action. Matching is case-sensitive and unicode-aware by default. For case-insensitive matching, add
(?i) to the beginning of your regular expression.
For examples of ways to use the Filter Action in the Pipeline, check out our Filter Pipeline Step Example Scenarios.
Hide a column in your query results by clicking Hide column in its Column Actions menu. Once you hide a column, it won’t show in your Result Table. If you need to use hidden columns in a Formula, hide the columns as the last step. Columns must be present in the Result Table to use in other Actions, aggregations, or custom formulas.
Limit the number of rows included in your query results. This can be useful when applied after a sort. For example, sort sales in descending order and limit rows to 10 to show the top 10 sales. Offset allows you to select a specific range of rows. For example, to include only rows 10-30, set the limit to 20 and the offset to 10.
If you’re trying to limit the rows of your initial Query, you could modify the row limits in the Query Action itself rather than adding a separate Limit Rows Action.
If your chart has one numeric column grouped by two categorical columns, such as count of activity grouped by month and by activity type, you’ll want to pivot the data so you can use it in a chart.
Pivot tables require 3 columns. Your data is pivoted on the second column—i.e., the second column becomes the column headers.
- Click Pivot above the Result Table.
- Select Unsorted, Ascending, or Descending for the column sort direction to customize the column order in your pivot table.
- Choose the aggregation for duplicate group values; the available aggregations are SUM, AVG, MIN, MAX, GROUP_CONCAT, and Auto. Auto will choose either SUM or GROUP_CONCAT, depending on the data type.
- Click Save to apply the pivot.
Rename a column by clicking Rename column from its Column Actions menu. This is useful for display purposes or shortening column names for ease of use in formulas. Once you rename a column, you’ll use the new name in all future Actions.
Reorder columns in your result set. There are a couple different ways to reorder columns:
Reorder Columns (Table Action) allows you to quickly drag and drop columns in the Result Table to put them in the desired order.
Move to Start or Move to End (Column Actions) makes the column the first or last column in the table, respectively.
Apply an ascending or descending sort to a column’s results from its Column Actions menu. Keep in mind that sorting isn’t nested like it is in a Query. If you add multiple Sort Actions, the last one listed in the Pipeline takes precedence. All the other Sort Actions before it will basically be ignored.
Zero Fill fills in missing values in your data with zeros. It’s important when charting a time series with missing dates, or when performing calculations on columns that contain NULL values.
Note: Zero Fill will fill in all date and numeric columns in your query results.
Zero Fill example
Before Zero Fill:
After Zero Fill: