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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.