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
req77
Helper I
Helper I

Column that counts the number of occurrences on each row

Hello,

My table follows this structure:

Name       Response
Alex     
  [{"title":"hello, there","satisfaction":"true"},{"title":"response number 2","satisfaction":"true"},
        {"title":"response number 3","satisfaction":"false"}]

Alfred    
  [{"title":"hello, there","satisfaction":"true"},{"title":"response number 2","satisfaction":"true"},
        {"title":"response number 3","satisfaction":"true"},
        {"title":"response number 4","satisfaction":"true"},
        {"title":"response number 5","satisfaction":"true"}]


I would like to create a new column that counts the number of occurrences of the word "true" in the Response column for each row in my table.

My expected result would be something like this:

Name       ResponseNumber of Occurrences
Alex   
  [{"title":"hello, there","satisfaction":"true"},{"title":"response number 2","satisfaction":"true"},
        {"title":"response number 3","satisfaction":"false"}]

                2
Alfred    
  [{"title":"hello, there","satisfaction":"true"},{"title":"response number 2","satisfaction":"true"},
        {"title":"response number 3","satisfaction":"true"},
        {"title":"response number 4","satisfaction":"true"},
        {"title":"response number 5","satisfaction":"true"}]

                5


Can someone help me?

2 ACCEPTED SOLUTIONS
samdthompson
Memorable Member
Memorable Member

Hello, this will work:

 

COUNT = (LEN('Table'[Response])-LEN(SUBSTITUTE('Table'[Response],"true","")))/LEN("true")
 
// if this is a solution please mark as such. Kudos always appreciated.

View solution in original post

This is perfect! Thank you 🙂

View solution in original post

2 REPLIES 2
samdthompson
Memorable Member
Memorable Member

Hello, this will work:

 

COUNT = (LEN('Table'[Response])-LEN(SUBSTITUTE('Table'[Response],"true","")))/LEN("true")
 
// if this is a solution please mark as such. Kudos always appreciated.

This is perfect! Thank you 🙂

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.