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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Count a Row if an Entry Exists in Any Column

Hi,

I'm interested in counting the row if the term 'Motorist Assist' exists anywhere within several columns. So my total should be 23 say if I put this column in a Table visualization. Any suggestions?

Thanks in advance.

EventIDResp1TypeResp2TypeResp3TypeResp4Type
468734Motorist Assist   
468735Motorist Assist   
468736Motorist Assist   
468737Motorist Assist   
468738Highway PatrolMotorist Assist  
468739Motorist Assist   
468740PoliceFireEMS 
468741Police   
468742Motorist Assist   
468743Motorist Assist   
468744Motorist Assist   
468745Motorist Assist   
468746TowPoliceFireEMS
468747Motorist Assist   
468748Motorist Assist   
468749Motorist Assist   
468750Motorist Assist   
468751Motorist Assist   
468752Motorist Assist   
468753Motorist Assist   
468754Motorist Assist   
468755Motorist Assist   
468757TowPoliceMotorist Assist 
468759PoliceFireEMSMotorist Assist
468758Motorist Assist   
468760DOTPoliceMotorist AssistMotorist Assist
2 ACCEPTED SOLUTIONS
AlB
Super User
Super User

Hi @Anonymous 

Create this measure and place it in a  card visual:

Measure =
VAR auxT_ =
    FILTER (
        Table1,
        VAR concat_ = Table1[Resp1Type] & Table1[Resp2Type] & Table1[Resp3Type] & Table1[Resp4Type]
        RETURN
            SEARCH ( "Motorist Assist", concat_,, 0 ) > 0
    )
RETURN
    COUNTROWS ( auxT_ )

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

View solution in original post

jdbuchanan71
Super User
Super User

@Anonymous 

One way to do it would be 

Measure =
CALCULATE (
    COUNTROWS ( 'Table' ),
    FILTER (
        'Table',
        'Table'[Resp1Type] = "Motorist Assist"
            || 'Table'[Resp2Type] = "Motorist Assist"
            || 'Table'[Resp3Type] = "Motorist Assist"
            || 'Table'[Resp4Type] = "Motorist Assist"
    )
)

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

In the Query Editor, right click on the first column and select "Unpivot other columns".  Now write this measure

=calculate(countrows(data),data[value]="Motorist assist")

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
jdbuchanan71
Super User
Super User

@Anonymous 

One way to do it would be 

Measure =
CALCULATE (
    COUNTROWS ( 'Table' ),
    FILTER (
        'Table',
        'Table'[Resp1Type] = "Motorist Assist"
            || 'Table'[Resp2Type] = "Motorist Assist"
            || 'Table'[Resp3Type] = "Motorist Assist"
            || 'Table'[Resp4Type] = "Motorist Assist"
    )
)
AlB
Super User
Super User

Hi @Anonymous 

Create this measure and place it in a  card visual:

Measure =
VAR auxT_ =
    FILTER (
        Table1,
        VAR concat_ = Table1[Resp1Type] & Table1[Resp2Type] & Table1[Resp3Type] & Table1[Resp4Type]
        RETURN
            SEARCH ( "Motorist Assist", concat_,, 0 ) > 0
    )
RETURN
    COUNTROWS ( auxT_ )

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.