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
raymond
Post Patron
Post Patron

Count if a value occurs in multiple columns per row

Dear Community,

 

Initial Situation:

There is a table of multiple columns: btn_A to btn_D. 

 

Sought Output as a new column:

The function should count how often a value such as "Interest" occurs in multiple columns. See Count_Interest

 

How can this be achieved?

 

2018-02-11 18_55_36-Mappe1 - Excel.png

1 ACCEPTED SOLUTION

@raymond

 

Similarly

 

Count_Conversion =
VAR RowValues =
    UNION (
        ROW ( "MyTable", TableName[btn_A] ),
        ROW ( "MyTable", TableName[btn_B] ),
        ROW ( "MyTable", TableName[btn_C] ),
        ROW ( "MyTable", TableName[btn_D] )
    )
RETURN
    COUNTROWS ( FILTER ( RowValues, [MyTable] = "Conversion" ) )

Regards
Zubair

Please try my custom visuals

View solution in original post

3 REPLIES 3
MARSU95
Regular Visitor

Hello, 
I treied this but didn't work in power Query neither in DAX 😕

Zubair_Muhammad
Community Champion
Community Champion

@raymond

 

Try As a caclulated column

 

Count_Interest =
VAR RowValues =
    UNION (
        ROW ( "MyTable", TableName[btn_A] ),
        ROW ( "MyTable", TableName[btn_B] ),
        ROW ( "MyTable", TableName[btn_C] ),
        ROW ( "MyTable", TableName[btn_D] )
    )
RETURN
    COUNTROWS ( FILTER ( RowValues, [MyTable] = "Interest" ) )

 

 


Regards
Zubair

Please try my custom visuals

@raymond

 

Similarly

 

Count_Conversion =
VAR RowValues =
    UNION (
        ROW ( "MyTable", TableName[btn_A] ),
        ROW ( "MyTable", TableName[btn_B] ),
        ROW ( "MyTable", TableName[btn_C] ),
        ROW ( "MyTable", TableName[btn_D] )
    )
RETURN
    COUNTROWS ( FILTER ( RowValues, [MyTable] = "Conversion" ) )

Regards
Zubair

Please try my custom visuals

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.