CONTAINSROW

How to Use the Power BI DAX function CONTAINSROW

Overview of the CONTAINSROW function

The CONTAINSROW function is a logical function that returns true or false if a table contains a specific row. The function takes two parameters, the first parameter is a table, and the second parameter is a row that needs to be checked in the table.

Here’s the syntax of the function:


CONTAINSROW ( ❰table❱, ❰row❱ )


The first parameter is the table, and the second parameter is the row that we want to check. The row must be enclosed in curly braces {} and must include all the columns that we want to check in the table.

How to use the CONTAINSROW function

To use the CONTAINSROW function, follow the steps below:

1. Open Power BI Desktop.

2. Create a new report or open an existing report.

3. Click on the 'Modeling' tab in the ribbon.

4. Click on 'New Table' in the 'Calculations' group.

5. In the formula bar, type the following formula:


Table1 = {

{ “Value1”, “Value2”, “Value3” },

{ “Value4”, “Value5”, “Value6” },

{ “Value7”, “Value8”, “Value9” }

}


6. Replace the values in the table with the values that you want to use.

7. Press Enter to create a new table.

8. Click on the 'Report' tab in the ribbon.

9. Click on 'New Visual' in the 'Visualizations' group.

10. Select a visual that you want to use.

11. Add the 'Table1' table to the visual.

12. Add a new measure to the 'Table1' table.

13. In the formula bar, type the following formula:


Contains Value3 = CONTAINSROW ( Table1, {“”, “”, “Value3”} )


14. Press Enter to create the measure.

15. Add the new measure to the visual.

The visual should now display the value 'True' for the row that contains 'Value3' and 'False' for the other rows.

The CONTAINSROW function is a powerful tool in Power BI that helps to determine if a table contains a specific row. By using this function, we can easily check if a row exists in a table and get the desired results. In this article, we have explored how to use the CONTAINSROW function in Power BI to get the desired results.

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)