CURRENTGROUP

How to Use the Power BI DAX function CURRENTGROUP

Understanding the CURRENTGROUP function

The CURRENTGROUP function is used to return a table that contains all the rows within the current group. In other words, if you have a table that is grouped by a certain column, the CURRENTGROUP function will return all the rows that belong to the current group.

For example, let’s say you have a table that contains sales data for different regions. If you group the data by region, the CURRENTGROUP function will return all the rows that belong to the current region. This is particularly useful when you want to perform calculations on a subset of data within a group.

Syntax

The syntax for the CURRENTGROUP function is as follows:


CURRENTGROUP([column1], [column2], …)


The function takes one or more columns as arguments and returns a table containing all the rows within the current group. If no arguments are provided, the function will return all the columns in the current group.

Using CURRENTGROUP in Power BI

To use the CURRENTGROUP function in Power BI, follow these steps:

1. Create a table visual in Power BI.

2. Group the table by one or more columns.

3. Create a calculated column using the CURRENTGROUP function.

For example, let's say you have a table that contains sales data for different regions, and you want to calculate the percentage of total sales for each region. Here's how you can do it using the CURRENTGROUP function:

1. Create a table visual in Power BI.

2. Group the table by the "Region" column.

3. Create a calculated column using the following DAX formula:


Sales Percentage = [Sales] / SUMX(CURRENTGROUP(), [Sales])


This formula will divide the sales for each region by the total sales for the current group (i.e., all the regions).

The CURRENTGROUP function is a powerful tool that can be used to perform calculations on subsets of data within a group. It is particularly useful when working with large datasets and can help you generate insights quickly and easily. By following the steps outlined in this article, you can start using the CURRENTGROUP function in your own Power BI reports and dashboards.

Power BI DAX Training Courses by G Com Solutions (0800 998 9248)

Upcoming Courses

6-8 Jun 23 (London or Online)
8-10 Aug 23 (London or Online)
24-26 Oct 23 (London or Online)

Contact Us

    Subject

    Your Name (required)

    Company/Organisation

    Email (required)

    Telephone

    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)