cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Regular Visitor

How to count/calculate number of elements/values seperated by commas in a column

I have a number of columns that contains multiple values/elements. (see picture)

Which function or formula allows me to retrieve the number of elements/members?

List Number of elements.png

1 ACCEPTED SOLUTION
Super User IV
Super User IV

Column = VAR originalLength = LEN([Text])
VAR replaceLength = LEN(SUBSTITUTE([Text],",",""))
RETURN originalLength - replaceLength + 1

---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
Super User IV
Super User IV

Column = VAR originalLength = LEN([Text])
VAR replaceLength = LEN(SUBSTITUTE([Text],",",""))
RETURN originalLength - replaceLength + 1

---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Sorry for my late replace. Didn't know you could define vars in a column definition.

This is what makes Power BI so powerful 🙂

Helpful resources

Announcements
secondImage

Congratulations!

We are excited to announce the Power BI Super Users!

Wave Release 2

Check out the updates in Power BI.

Overview of Power BI 2020 release wave 2!

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors