cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Lebunim
Regular Visitor

Count Keywords in Summary Column from another table

Hi Guys, 

I tried to find solution in the Forum but failed each and everytime. 

I'm actually looking for a simple thing, I have two tables :

1. Keywords

2. Incidents

 

I want to know how many times Keywords from Keywords Table occure in the Incidents Summary column. 

I just need a count. In Excel COUNTIF worked perfect but I wanted to extend that functionality into PBI.

 

Can You please help me created a formula for Count of Word Appearance column in Table 1? 

 

Table 1 - Keywords Table 2 - Incidents
KeywordsCount of word appearance  Summary
issue 2 The phone has an issue with application 
down 0 more text with issues
is down 0 each ticket has summary with outage description 
has problem 1 outlining the problem 
outage 1 and the so on….
application 1  
server 0  
phone1  

 

 

Can You please help me created a formula for Count of Word Appearance column in Table 1?

 

Many thanks, 

 

1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @Lebunim ,

 

You can try use substitute() to replace the word in this summary string to null. Then calculate the reduced number of characters, finally divide it by the length of keyword.

Modify the measure to suit your mode.

count word =
VAR _text =
    FIRSTNONBLANK ( 'Table 2 - Incidents'[text], 1 )
VAR _len_text =
    LEN ( _text )
VAR _len_key =
    LEN ( [Keywords] )
VAR _substitute =
    LEN ( SUBSTITUTE ( _text, [Keywords], "" ) )
RETURN
    DIVIDE ( _len_text - _substitute, _len_key )

 

Result: 

vchenwuzmsft_1-1646030492567.png

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

View solution in original post

5 REPLIES 5
v-chenwuz-msft
Community Support
Community Support

Hi @Lebunim ,

 

You can try use substitute() to replace the word in this summary string to null. Then calculate the reduced number of characters, finally divide it by the length of keyword.

Modify the measure to suit your mode.

count word =
VAR _text =
    FIRSTNONBLANK ( 'Table 2 - Incidents'[text], 1 )
VAR _len_text =
    LEN ( _text )
VAR _len_key =
    LEN ( [Keywords] )
VAR _substitute =
    LEN ( SUBSTITUTE ( _text, [Keywords], "" ) )
RETURN
    DIVIDE ( _len_text - _substitute, _len_key )

 

Result: 

vchenwuzmsft_1-1646030492567.png

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

mh2587
Solution Sage
Solution Sage

create calculated column 

Match = 
var _cname = 'Table'[Customer Name]
var _iname = 'Table'[Invoice Customer]
var _firstname = LEFT(_cname,SEARCH(" ",_cname)-1)
var _lastname = MID(_cname,SEARCH(" ",_cname)+1,LEN(_cname))
return
IF(
    EXACT([Customer Name],[Invoice Customer]),
    "Match",
    IF(
           NOT(CONTAINSSTRING(_iname,_firstname))&&NOT(CONTAINSSTRING(_iname,_lastname)),
           "Not Match",
           IF(
               CONTAINSSTRING(_iname,_firstname)||CONTAINSSTRING(_iname,_lastname),
               "Partial Match"
           )
    )
)

And modify with your requirements



Muhammad Hasnain

#LetsConnect https://www.linkedin.com/in/hasnain2587/
mh2587
Solution Sage
Solution Sage

https://community.powerbi.com/t5/Desktop/Extract-numerous-Key-words-from-sentences-in-a-cloumn/td-p/...



Muhammad Hasnain

#LetsConnect https://www.linkedin.com/in/hasnain2587/
Samarth_18
Community Champion
Community Champion

Hi @Lebunim ,

 

Create a measure like below:-

Count of word appearance =
COUNTROWS (
    FILTER (
        _Incidents,
        CONTAINSSTRING ( _Incidents[Summary], MAX ( _Keyword[Keywords] ) )
    )
) + 0

Output:-

Samarth_18_0-1645601864540.png

 

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

What does the MAX represent in above example. I'm getting some values but not exactly as I would expect it. 

This measure returns rows with "exact" match of the Keyword, it does not identify a keyword in between other text..... 

Example 1 : would count "application"

Example 2 : would not count " my new application is down" 

 

I'm not sure why but it seems the above measure counts rows with exact match of the keyword, anything with additional text is being skipped....

 

Any ideas?

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors