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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
pbrenneise
Frequent Visitor

Assistance with Dax formula for occurrence of character in column

Hi folks,

 

Is there an efficient Dax formula I can use to count the number of occurences of a particular special character in a column based on conditions? The column looks something like this:

 

Column A
Bill Murray
 
John Doe; Joe Biden; Bill Gates
Mark Twain; Paul Bunyan; Jack Black
Stevie Wonder; Erica Karros

 

Due to the presence of the occasional blank cell, I need ensure that only cells with characters in them are counted, which led me to COUNTA() (not every cell has as a delimiter next to a user's name (e.g. if only one user is listed)). The logic I was considering involved firstly testing to ensure the cell wasn't blank, and then I needed to start counting the number of delimiters in each row with a base count of 1 (again to account for cells with text in them, but do not contain the delimiter in question). Hope that makes sense and appreciate the help, particularly if there's an easier way to do this. I didn't want to unpivot the column and count that way in Power Quert since the table is already too big.

Best,

 

pbrenneise

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@pbrenneise Try:

Column = LEN([Column A]) - LEN(SUBSTITUTE([Column A],";",""))

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
pbrenneise
Frequent Visitor

That helped - appreciate the assistance!

Greg_Deckler
Super User
Super User

@pbrenneise Try:

Column = LEN([Column A]) - LEN(SUBSTITUTE([Column A],";",""))

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.