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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Betty888
Helper II
Helper II

How to count the occurence of a value from a column in a coma separated field in another column?

Dear all, 

I'm trying to count the number of occurence of a value from column "Date" in a list of dates with a semicolon separator in another column "Column B" as below : 

DateColumn B
date1date1; date2;date3;date4;date5;date6; ,,,,,
date2date1; date2;date3;date4;date5;date6; ,,,,,
date3date1; date2;date3;date4;date5;date6; ,,,,,
date4 date1; date2;date3;date4;date5;date6; ,,,,,

 

Can you help me with any ideas, please 🙏

Thank you in advanace for your help ! 

Regards, 

2 ACCEPTED SOLUTIONS
Moetazzahran
Resolver II
Resolver II

Hello @Betty888

I created this calculated column which uses two main variables
The first variable 

OccurrenceLength is the difference between the length of the text of [ColumnB] and the length of the same text after it replaces the variable in [Date] with a blank().

This difference in length will then be divided by the length of the variable we replaced within the string to get the number of occurance of the variable you are searching for within the ColumnB 
Moetazzahran_0-1718672420444.png

Please let me know if this works, and accept it as a solution if it does. You are kudo is also much appreciated.

View solution in original post

Anonymous
Not applicable

Hi, @Betty888 

You can create a custom column and use the following M expression in PowerQuery. This formula splits the text in "Column B" by semicolon and counts the number of elements after splitting. It then adds one to the count result. If there is no data after the semicolon, we need to subtract one from it.

 

= List.Count(Text.Split([Column B], ";"))-1

 

vyohuamsft_1-1718673996441.png

Here is my preview:

vyohuamsft_0-1718673889443.png

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi, @Betty888 

You can create a custom column and use the following M expression in PowerQuery. This formula splits the text in "Column B" by semicolon and counts the number of elements after splitting. It then adds one to the count result. If there is no data after the semicolon, we need to subtract one from it.

 

= List.Count(Text.Split([Column B], ";"))-1

 

vyohuamsft_1-1718673996441.png

Here is my preview:

vyohuamsft_0-1718673889443.png

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thanks a lot ! 

In fact, your suggested solution counts the number of items, but what I need is to count the number of occurence of value from column "Date" in "Column B".

Regards,

Moetazzahran
Resolver II
Resolver II

Hello @Betty888

I created this calculated column which uses two main variables
The first variable 

OccurrenceLength is the difference between the length of the text of [ColumnB] and the length of the same text after it replaces the variable in [Date] with a blank().

This difference in length will then be divided by the length of the variable we replaced within the string to get the number of occurance of the variable you are searching for within the ColumnB 
Moetazzahran_0-1718672420444.png

Please let me know if this works, and accept it as a solution if it does. You are kudo is also much appreciated.

Many thanks ! 
it works for my problem, many many thanks ! 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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