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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Rana80
Frequent Visitor

CONTAINSSTRING with counting rows

Hi 

 

I'm  trying to create an calculated column that counts how many times the phrase 

"marked this task as resolved" occurs for each Task ID

 

I have done this with a calculated column call 'Time to Complete Flag' by;

 

Time to Complete Flag =

    IF(
    CONTAINSSTRING( crda9_messenger_messages[Message], "marked this task as resolved" ),
    1,
    BLANK()

 

Current:

Rana80_1-1695301551689.png

 

What i want it to do is it increment the count by 1 if there is more than 1 iteration of  "marked this task as resolved". For Task ID AAA & BBB there is only one iteration of the text. However for Task ID CCC has 2 interations and i want it to count these  in asending order from the Created On date field so the output looks like the below so i can perform a max query on the next analysis.

 

I'm sure my CONTAINSTRING needs extending but i'm unsure how in DAX.

 

Need:

Rana80_2-1695301593136.png

Thank you all!

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

pls try this

Column = VAR t1 = 'Table'[Task JD]
VAR t2 =
    CONTAINSSTRING('Table'[Message],"marked this task as resolved")
VAR tbl =
    FILTER(ALL( 'Table' ),
        'Table'[Task JD] = t1&& 
            CONTAINSSTRING('Table'[Message],"marked this task as resolved" )= TRUE)
RETURN
    IF( t2, RANKX( tbl, 'Table'[Created On], , ASC, DENSE ) )

Screenshot_1.png

View solution in original post

2 REPLIES 2
Ahmedx
Super User
Super User

pls try this

Column = VAR t1 = 'Table'[Task JD]
VAR t2 =
    CONTAINSSTRING('Table'[Message],"marked this task as resolved")
VAR tbl =
    FILTER(ALL( 'Table' ),
        'Table'[Task JD] = t1&& 
            CONTAINSSTRING('Table'[Message],"marked this task as resolved" )= TRUE)
RETURN
    IF( t2, RANKX( tbl, 'Table'[Created On], , ASC, DENSE ) )

Screenshot_1.png

Rana80
Frequent Visitor

Perfect! Thank you very much.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors