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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
dubya
Regular Visitor

Attempting to count affected rows, not total occurrences of a keyword!

Hello, 

 

I am attempting to count the number of application's comments that include a key word, not the total count of the keyword. 

 

i.e. creating the measure on the right from the table on the left. 

Capture.JPG

 

 

I have put together this measure, but this counts the total amount of keyword occurences. 

 

Applications with Keywords Count Measure =
VAR _search_word =
    SELECTEDVALUE ('Keywords Table'[Keywords])
VAR _result =
    CALCULATE (
        COUNTROWS ( 'Application Detail Table' ),
        CONTAINSSTRING ( 'Application Detail Table'[Comments], _search_word )
    )
RETURN
    _result
 
Please help!
 
Thank you! 
2 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

Does it have to be DAX?

 

Keywords:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs/PT1GK1YlWcixLLUpMTwWznRKBYrEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Keyword = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Application count", (k)=> Table.RowCount(Table.SelectRows(#"Application Detail",each Text.PositionOf([Comments],k[Keyword])>-1)),Int64.Type)
in
    #"Added Custom"

 

Application Count DAX = var k=[Keyword] return CALCULATE(countrows('Application Detail'),SEARCH(k,'Application Detail'[Comments],,0)>0)

 

lbendlin_0-1729636808135.png

 

 

View solution in original post

v-kaiyue-msft
Community Support
Community Support

Hi @dubya ,

 

You can try the following dax expression.

ApplicationsWithKeywordCount = 
VAR Keyword = SELECTEDVALUE('Keywords Table'[Keywords])
RETURN
CALCULATE(
    DISTINCTCOUNT('Application Detail Table'[Application #]),
    SEARCH(Keyword, 'Application Detail Table'[Comments], 1, 0) > 0
)

vkaiyuemsft_0-1729667518901.png

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

View solution in original post

2 REPLIES 2
v-kaiyue-msft
Community Support
Community Support

Hi @dubya ,

 

You can try the following dax expression.

ApplicationsWithKeywordCount = 
VAR Keyword = SELECTEDVALUE('Keywords Table'[Keywords])
RETURN
CALCULATE(
    DISTINCTCOUNT('Application Detail Table'[Application #]),
    SEARCH(Keyword, 'Application Detail Table'[Comments], 1, 0) > 0
)

vkaiyuemsft_0-1729667518901.png

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

lbendlin
Super User
Super User

Does it have to be DAX?

 

Keywords:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs/PT1GK1YlWcixLLUpMTwWznRKBYrEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Keyword = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Application count", (k)=> Table.RowCount(Table.SelectRows(#"Application Detail",each Text.PositionOf([Comments],k[Keyword])>-1)),Int64.Type)
in
    #"Added Custom"

 

Application Count DAX = var k=[Keyword] return CALCULATE(countrows('Application Detail'),SEARCH(k,'Application Detail'[Comments],,0)>0)

 

lbendlin_0-1729636808135.png

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.