Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Countrows if text is in one or the other column

Hi,

I have two columns where I want to find data and then count the number of rows found.

 

SWPR
SWSW
PRSS
TRTR

 

In the table above how can I count the number of rows where SW appears? Result expected would be 2.

 

I was trying to use the following, but successful.

Count SW covered = CALCULATE(COUNTROWS('Table1'),SEARCH("SW",OR('Col1','Col2'),,0))
 

 

Thanks

1 ACCEPTED SOLUTION

In that case, you can use the following:

 

Count SW Rows =
COUNTROWS (
    FILTER (
        SearchTable,
        SEARCH (
            "SW",
            SearchTable[Column1],
            ,
            0
        ) > 0
            || SEARCH (
                "SW",
                SearchTable[Column2],
                ,
                0
            ) > 0
    )
)

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

6 REPLIES 6
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Please let us know if the latest reply of @mahoneypat could meet your requirements.

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

mahoneypat
Microsoft Employee
Microsoft Employee

Please try this measure to get the rows with SW in them.  Replace SearchTable with your actual table name.

 

Count SW Rows = COUNTROWS(FILTER(SearchTable, "SW" in {SearchTable[Column1], SearchTable[Column2]}))
 
FYI you can use this expression to count the overall # of SW values.
Count SW = SUMX(SearchTable, COUNTROWS(FILTER({SearchTable[Column1], SearchTable[Column2]}, [Value] = "SW")))
 
Pat




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Thanks. It does work.

I forgot to mention that sometimes is not explicitly written SW, but ASW or BSW. I've tried to use wildcards "*SW*" but it did not produce any result.

In that case, you can use the following:

 

Count SW Rows =
COUNTROWS (
    FILTER (
        SearchTable,
        SEARCH (
            "SW",
            SearchTable[Column1],
            ,
            0
        ) > 0
            || SEARCH (
                "SW",
                SearchTable[Column2],
                ,
                0
            ) > 0
    )
)

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Hi @Anonymous 

Count SW covered = CALCULATE(COUNTROWS('Table1'),SEARCH("SW",[Col1]) > 0  ||   SEARCH("SW",[Col2]) > 0)

Anonymous
Not applicable

Hello,

It does not work. Throws this error

 

The expression contains multiple columns, but only a single column can be used in a True/False expression that is used as a table filter expression.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors