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
Adalapc
New Member

count how many times a word appears in each cell

Hi all,

I need to count how many times a word appears in each cell. (are logs of an application)

Ex.:
Text
Doc A Saved, Doc B Error, Doc C Saved, Doc D Attention

I need to count how many times the word "saved" appears, in the example above 2 times.

1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

Hi @Adalapc 

 

try this

CountColumn = (len('Table'[Text])-len(substitute('Table'[Text];"Saved";"")))/len("Saved")

you canalso store your replaced word in the new column SavedText and change "Saved" in the formula on 'Table'[SavedText]


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

3 REPLIES 3
Icey
Community Support
Community Support

Hi @Adalapc ,

I modified @az38 's expression:

CountMeasure =
SUMX (
    'Table',
    CALCULATE (
        DIVIDE (
            LEN ( MAX ( 'Table'[Text] ) )
                - LEN ( SUBSTITUTE ( MAX ( 'Table'[Text] ), "Saved", "" ) ),
            LEN ( "Saved" )
        )
    )
)

count1.PNG

Best Regards,

Icey

 

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

 

az38
Community Champion
Community Champion

Hi @Adalapc 

 

try this

CountColumn = (len('Table'[Text])-len(substitute('Table'[Text];"Saved";"")))/len("Saved")

you canalso store your replaced word in the new column SavedText and change "Saved" in the formula on 'Table'[SavedText]


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Where do we put this?

CountColumn = (len('Table'[Text])-len(substitute('Table'[Text];"Saved";"")))/len("Saved")

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.