# cfxdm - dm:groupby

**dm:groupby:** This cfxdm tag allows the user to group the data (by rows) based on selected columns using aggregate functions.

**dm:groupby** synta&#x78;**:**&#x20;

* **columns** (mandatory)**:** Select one or more columns for grouping the data.
* **agg** (optional)**:**
  * **count:** It is applied by default when 'agg' is not specified. Supported on any value types (numeric or non-numeric values)
  * **min:** Supported on numeric values only
  * **max:** Supported on numeric values only
  * **sum:** Supported on numeric values only

In the below example, for a reference, we are going to use **VMware vCenter** as an extension to query the data from VMs tag and their disk size.

Enter the below command to select **VMware vCenter VMs tag (\*vcenter:vms**). (In this example, **vcenter** name is used as a label to identify VMware vCenter extension and it's tags. The label is defined while adding the extension in cfxdx configuration file or through UI)

```
tag *vcenter:vms
```

![](/files/-MW6us2YRudI68Vogt0D)

**Example-1:**&#x20;

Get the VM's list from the above tag and select the below columns  (as shown)

* vm\_name
* disk\_capacity\_kb
* bios\_uuid

```
data * get name as 'vm_name',disk_capacity_KB as 'disk_capacity_kb',id as 'bios_uuid'
```

Pipe the data to **dm:groupby** tag to view the data grouped by VM Name.

{% hint style="info" %}
Since '**agg**' option is not specified within the **dm:groupby** tag, it applies agg function '**count**' by default.
{% endhint %}

```
data * get name as 'vm_name',disk_capacity_KB as 'disk_capacity_kb',id as 'bios_uuid' --> dm:groupby columns = 'vm_name'
```

![](/files/-MW7BrfFCYO5_59TAriy)

**Example-2:**&#x20;

Continuing with above data, lets use agg function '**sum**' to calculate total VM's disk size.&#x20;

{% hint style="info" %}
When agg function '**sum**' is used, it automatically applies on all eligible columns (numerical values).&#x20;
{% endhint %}

```
data * get name as 'vm_name',disk_capacity_KB as 'disk_capacity_kb',id as 'bios_uuid' --> dm:groupby columns = 'vm_name' & agg = 'sum'
```

![](/files/-MW7E2ELU-mkLfZt_jnL)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cloudfabrix.io/rda/rda-userguide/rda-data-management-cfxdm/cfxdm-dm-groupby.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
