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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
EddP
Frequent Visitor

Contains counter

I have a column with text and i'm trying to create a measure that will count the amount of times two words appear together.

 

For example:

Word 1: Text 1

Word 2: Text 2

 

Text 1 - Text 1 - Text 1 - Text 2
Text 1 - Text 3 - Text 1 - Text 3
Text 1 - Text 2 - Text 1 - Text 1
Text 1 - Text 2 - Text 1 - Text 1

Text 1 - Text 1 - Text 1 - Text 3

Text 1 - Text 1 - Text 1 - Text 3

Text 1 - Text 1 - Text 1 - Text 4

 

Result: 3 (as text 1 and text 2 appear together on 3 different rows)

 

I have the following dax that converts selections in splicers to strings:

 

Mutual_Counter =
    VAR t1 = CONVERT(SELECTEDVALUE(Steps_Affiliate[taxonomy_4]),STRING)
    VAR t2 = CONVERT(SELECTEDVALUE(Steps_Affiliate[taxonomy_4 Filter_2]),STRING)
    VAR inp = CONCATENATE(t1, t2)
    return
    CALCULATE(
        COUNT(Paths[path_taken]),
        CONTAINSSTRING(Paths[path_taken],inp)
    )

 

The code doesn't error, but nothing is returned. Am i using the wrong contains? Or is something else off.

 

TIA

1 REPLY 1
tamerj1
Super User
Super User

Hi @EddP 

perhaps you need to include the delimiter (seperator) and spaces. 
VAR inp = t1 & " - " & t2

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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