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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
BenGWeeks
Regular Visitor

Custom Column Query

I would like to create a column that counts the number of items in a comma separated striong as follows:

 

BenGWeeks_0-1632401924502.png


However, the ProjectCount column is currently returning errors (and needs an IF statement added if the project string has no commas the count should be 1).

 

BenGWeeks_1-1632402058169.png

 

This then splits the cost based on how many projects for each row. I shall then be splitting/pivoting the table on the projects.

 

Any help much appreciated.

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @BenGWeeks ,

 

Try using this calculation instead:

 

if [Projects] = null then 0 else List.Count(List.PositionOf(Text.ToList([Projects]), ",", Occurrence.All)) + 1

 

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

2 REPLIES 2
BA_Pete
Super User
Super User

Hi @BenGWeeks ,

 

Try using this calculation instead:

 

if [Projects] = null then 0 else List.Count(List.PositionOf(Text.ToList([Projects]), ",", Occurrence.All)) + 1

 

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




amitchandak
Super User
Super User

@BenGWeeks , This power query code used in DAX new column. Please open data transformation and try it there.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.