Forum Discussion

ahhk2000's avatar
ahhk2000
Copper Contributor
Nov 10, 2022
Solved

Formula to count occurences of text string in DAX

I have the following formula to count the occurrences of the word "forum" in a column (L with Comment header).

 

=COUNTIF($L$2:$L$4000,”*forum*”)

 

It should count the word occuring in any part of the text (e.g. "thank you for inviting me to the forum", "goodforum" [sic])

 

I would like to replicate it with DAX to use in a Power Pivot table. I have tried the following measure that I found on an earlier post, however the numbers counted seem much lower.

 
=SUMX(AllResults, 1*(FIND(“forum”, ALLResults[Comment],,0)>0))
 
Any advice would be appreciated.

2 Replies

  • Riny_van_Eekelen's avatar
    Riny_van_Eekelen
    Platinum Contributor

    ahhk2000 

    Such a measure could like something like this:

     

    =SUMX(AllResults,IF(CONTAINSSTRING ([Comment], "forum"),1,0))

    • ahhk2000's avatar
      ahhk2000
      Copper Contributor
      Thanks very much. This works perfectly... unfortunately the measure doesn't seem to exist in Excel 2016, but I got it working in Power BI.

Resources