ROW

How to Use the Power BI DAX function ROW

What Is the ROW Function in Power BI?

The ROW function in Power BI is a DAX function that returns the row number of a specified cell within a given table. The syntax of the ROW function is as follows:


ROW(❰table❱)


Where `❰table❱` is the name of the table that contains the cell you want to reference.

When used within a calculated column or measure, the ROW function returns the row number of the current row context. This can be useful when you want to reference a specific cell or row within a table.

How to Use the ROW Function in Power BI

The ROW function can be used in a variety of ways within Power BI. Here are some examples:

1. Reference a Specific Cell

Suppose you have a table that contains sales data for a particular product. You want to create a measure that calculates the percentage of total sales for each product. To do this, you need to reference the total sales for each product and divide it by the total sales for all products. You can use the ROW function to reference the total sales for each product as follows:


Sales Percentage =

SUM(Sales[Sales]) / CALCULATE(SUM(Sales[Sales]), ALL(Sales))


In this example, the ROW function is not explicitly used, but it is used implicitly within the SUM function to reference the total sales for the current row context.

2. Reference a Specific Row

Suppose you have a table that contains sales data for multiple regions and you want to create a measure that calculates the average sales for a particular region. You can use the ROW function to reference a specific row within the table as follows:


Region Average Sales =

CALCULATE(

AVERAGE(Sales[Sales]),

Sales[Region] = “North”,

ROW(Sales[Region]) = ROW(“North”)

)


In this example, the ROW function is used to reference the row number of the "North" region in the Sales table. This allows you to reference a specific row within the table and retrieve the average sales for that region.

3. Create a Dynamic Range

Suppose you have a table that contains sales data for multiple products and you want to create a chart that displays the top 10 products by sales. You can use the ROW function to create a dynamic range that includes only the top 10 products as follows:


Top 10 Products =

VAR TopRows = 10

VAR TotalRows = COUNTROWS(Sales)

RETURN

IF(ROW(Sales[Product]) ❰= TopRows, Sales[Product])


In this example, the ROW function is used to reference the current row number of the Sales[Product] column. This allows you to create a dynamic range that includes only the top 10 products by sales.

The ROW function is a powerful DAX function that can be used in a variety of ways within Power BI. It allows you to reference specific cells and rows within a table, create dynamic ranges, and perform complex calculations. By understanding how to use the ROW function, you can improve your data analysis and create more robust reports and dashboards in Power BI.

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

Upcoming Courses

Contact Us

    Subject

    Your Name (required)

    Company/Organisation

    Email (required)

    Telephone

    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)