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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
IvanMislav
Helper I
Helper I

Count of occurences within a row

I was wondering is there a function that could calculate number of occurences within one row? 

For example, i want to calculate the number of times word "red" occures within a row.

 

Result would look something like this:

 

 

     Color                |  Red  |  Blue

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

 Red, Blue, Red      |   2     |  1

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

  Red, Red, Red      |    3    |   0

 

Thanks

1 REPLY 1
Anonymous
Not applicable

Hi @IvanMislav ,

The following DAX might work for you:

Red = var a=ADDCOLUMNS(GENERATESERIES(1,PATHLENGTH(max(Table1[Column]))),"Item",PATHITEM(MAX(Table1[Column]),[Value]))
return COUNTROWS(FILTER(a,[Item]="red"))
blue = var a=ADDCOLUMNS(GENERATESERIES(1,PATHLENGTH(max(Table1[Column]))),"Item",PATHITEM(MAX(Table1[Column]),[Value]))
return COUNTROWS(FILTER(a,[Item]="blue"))+0

The final output is shown in the following figure:

vxiandatmsft_0-1698828176141.png

Best Regards,

Xianda Tang

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

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.