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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors