4. Query Block - Group by
Last updated
Last updated
The Group by section is used when you want to group the data in a table based on a certain criterion by creating multiple categories from a single column. For example, you can use it to view the total number of transactions sent by each address, or to compare the prices of all tokens. By using Group by, you can obtain the results of the calculation of Metrics for each group segment.
One thing to note is that as soon as you add a Group by clause, you will be calculating aggregated summaries for each group segment. Therefore, when calculating metrics, you should use an aggregate function for them to avoid errors.
You can click on the Group by input box and select the column you want to group by from the column list, or you can drag and drop the column from the left pane into the input box.
For a numeric column, the bin option is provided to create groups based on the range of values. Meaning, the system will calculate and categorize the data by the number of categories that you want to see. After selecting the column, you can choose one of the bin options to complete the addition. The range of the entire numbers is divided into groups of equal size based on the number of bins selected.
Adding another Group by
You can add a new Group by by clicking the +Group by button at the top or dragging a column from the left pane into the Group by area.
When setting up a Group by, you can use not only the data in the original table but also metadata information. For example, you can group the address column by the name of the address owner.
First, select the column to use in the Group by, then select Group by Metadata from the condition dropdown.
When you select it, an input field will appear asking you to choose which metadata field to match with.
For example, if the column you want to filter corresponds to an Ethereum address, select 'Ethereum Address'.
After selecting the matching field, choose which information to use to Group by. For example, if you want to group by the entity name of the address owner, select 'Entity Name'.