Billable Metrics screen: controls, columns, and filters
The Billable Metrics screen lists the billable metrics of your organization. To open it, go to Usage > Billable Metrics.Controls
| Control | Description |
|---|---|
| Search Billable Metric | Finds billable metrics whose name contains the text that you enter. Selecting a result opens the billable metric in the editor. |
| ADD NEW BILLABLE METRIC | Opens the Add New Billable Metric screen. |
| FILTER | Adds a filter to the list. See Filters. |
Columns
| Column | Content | Sortable |
|---|---|---|
| Name | The name of the billable metric. Click the row to open the billable metric in the editor. | Yes |
| Created At | The date when the billable metric was created. | Yes |
Filters
| Filter | Values | Conditions |
|---|---|---|
| Name | Text | Conditions for text, such as contains and equals |
| Created At | A date | Conditions for dates, such as is before |
Billable metric editor: builders, fields, and preview
ADD NEW BILLABLE METRIC opens the editor as the Add New Billable Metric screen. Clicking a billable metric in the list opens the editor with the name of the billable metric as its title.Header
| Control | Description |
|---|---|
| Pencil icon | It shows next to the name of a saved billable metric. It opens the Update Billable Metric Name window. UPDATE there saves the new name right away. |
| GO BACK | Returns to the previous screen without saving. |
| CREATE BILLABLE METRIC | It shows for a new billable metric. It opens the Choose Billable Metric Name window. CREATE BILLABLE METRIC there saves the billable metric. |
| SAVE CHANGES | It shows for a saved billable metric. It saves the changes. The editor stays open. |
| VISUAL BUILDER, SQL BUILDER | Switch between the builders. Clicking VISUAL BUILDER while it is unavailable opens the Visual Builder Disabled window. |
| Property | Constraint |
|---|---|
| CREATE BILLABLE METRIC | It is available on the last step of the visual builder, or in the SQL builder after EDIT is confirmed. |
| VISUAL BUILDER | After EDIT is confirmed in the SQL builder, VISUAL BUILDER is unavailable in the editor. |
| After the billable metric is saved as a query, VISUAL BUILDER stays unavailable. |
Visual builder
BACK and NEXT move between the four steps.| Step | Field | Details |
|---|---|---|
| Select tables & filters | Table Name | The table. Usage-event collections are listed under Usage Event by their API slug. Tables of synced usage data from synced data sources are listed under Data source. |
| + ADD FILTER | Adds a filter with Column, Condition, and Value. The conditions depend on the data type of the column. The delete icon removes the filter. | |
| + NEW FILTER GROUP | Adds a group of filters. The AND or OR button between filters or groups switches between AND and OR. CLEAR ALL FILTER GROUPS removes every group except the first. | |
| Map customer | Your customer column | The column that identifies the customer. The default is customer_id. |
| Zenskar customer column | email, external_id, customer name, or Custom attribute: <name>. The default is external_id. | |
| Set date field | Column | The column that dates each row. The default is timestamp. |
| Date Format | The format of the dates in the column. It shows when Column is not timestamp. | |
| Set Billable Metric over | Select calculation type | COUNT, SUM, MAX, AVG, MIN, or UNIQUE COUNT. The default is COUNT. See Calculation types: how the visual builder aggregates. |
| Select column to calculate over | The column that the calculation type applies to. |
| Property | Constraint |
|---|---|
| NEXT | NEXT does not move on when the table has no columns. |
| NEXT does not move on when a filter is incomplete. | |
| Table Name | The visual builder does not read remote data sources. |
| Zenskar customer column | A custom attribute shows only when it belongs to customers. |
| A custom attribute shows only when its custom attribute type is Text, Whole number, or Dropdown. |
SQL builder
| Control | Description |
|---|---|
| Editor | The query. A query on usage-event collections and synced usage data uses ClickHouse SQL. The format and copy icons format and copy the query. |
| SOURCE OF DATA | Synced Data or Remote Data. Synced Data covers the usage-event collections and the synced usage data. With Remote Data, Remote Datasource selects the data source. When a query that uses a remote data source switches to Synced Data, the Source Of Data Compatibility window opens, with PROCEED and CANCEL. |
| Data Navigator | Lists the tables and columns. The copy icon next to a table copies its name for the query. |
| Zenskar Variables | Lists the Zenskar SQL variables of the customer and the period. It also lists one variable for each custom attribute of the customer, the contract, and the product. See Zenskar SQL variables: values that Zenskar fills in. |
| Property | Constraint |
|---|---|
| Editor | The query is read-only until you click EDIT and confirm with YES in SQL Builder Edit Access. |
| After you save, the billable metric cannot return to the visual builder. | |
| Query | The query returns a column named quantity. Each other column that it returns is a dimension. |
| Zenskar rejects a query whose Zenskar SQL variables are not valid. | |
| SOURCE OF DATA | A query uses one kind of source. |
Query preview
| Control | Description |
|---|---|
| Search By Customer Name, External ID | The customer of the preview. In the visual builder, it is available from Map customer on. |
| Contract, Product | They show in the SQL builder when the query uses a contract or product variable. |
| Billing Period | The first and last days of the period. In the visual builder, it is available from Set date field on. |
| RUN QUERY | Runs the preview. In the SQL editor, Ctrl+Enter or Cmd+Enter also runs it. |
| Export Results | Downloads the result as a CSV file. |
| Property | Constraint |
|---|---|
| RUN QUERY | In the SQL builder, the preview runs only when each variable that the query uses has a value. |
| In the visual builder, the preview runs only when Billing Period has both dates. |
Permissions
| Action | Required permission |
|---|---|
| View billable metrics and open the editor | Can Read Billable Metric, in the BILLABLE_METRIC group |
| Preview a billable metric | Can Read Billable Metric |
| Create a billable metric | Can Read Billable Metric and Can Create Billable Metric |
| Edit a billable metric, move it to the SQL builder, or rename it | Can Read Billable Metric and Can Update Billable Metric |
| Delete a billable metric | Can Read Billable Metric and Can Delete Billable Metric |
API reference
| Operation | API reference |
|---|---|
| List billable metrics | List billable metrics |
| Get a billable metric | Get billable metric |
| Create a billable metric | Create billable metric |
| Update a billable metric | Update aggregate |
| Delete a billable metric | Delete aggregate |
Troubleshooting
| Problem | Cause | Solution |
|---|---|---|
| CREATE BILLABLE METRIC is unavailable. | The visual builder is not on Set Billable Metric over, or the SQL builder is still read-only. | Finish the four steps, or click EDIT and confirm. |
| NEXT does not move on. | The table has no columns, or a filter is incomplete. | Choose another table, or complete the filter. |
| The tables of a remote data source cannot be used in the visual builder. | The visual builder does not read remote data sources. | Build the billable metric in the SQL builder. |
| Zenskar rejects a query. | The Zenskar SQL variables of the query are not valid. | Correct the variables, as Zenskar SQL variables: values that Zenskar fills in describes them. |
| The preview does not run in the SQL builder. | The query uses a variable that has no value. | Select the customer, the contract, the product, or the dates that the query uses. |
| The preview does not run in the visual builder. | Billing Period lacks a date. | Select both dates of Billing Period. |
| The preview shows an error. | The query has an error. | Correct the query, and run the preview again. |
| A billable metric does not give a number for each combination of dimension values. | The visual builder cannot group rows by dimensions. | Move the billable metric to the SQL builder, and return the dimensions as columns. |
| VISUAL BUILDER is unavailable for a billable metric. | EDIT was confirmed in the SQL builder, or the billable metric was saved as a query. | Leave the editor without saving, or create a new billable metric in the visual builder. |
| A billing period has no quantity from a billable metric. | No rows matched. The query does not replace an empty result with 0. | To get 0 instead, replace an empty result with 0 in the query, such as with COALESCE, as Results for each customer and period describes. |