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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
fabiomanniti
Helper III
Helper III

Count in how many rows a certain substring occours

I have this type of table in Power BI:

 

ID |isPromoter |

path |

aaa-111-000 | false |

sqe-432-w14/2aq-4ec-t66/aaa-111-000/ |

sss-342-r34 | true | 

a3e-543-1sd/34d-245-svt/s3a-bnj-klo/sss-342-r34/ |

hhy-e90-y7u | false |

a3e-543-1sd/34d-245-svt/s3a-bnj-klo/sss-342-r34/hhy-e90-y7u/ |

... |... |

... |

 

So, as you can see, the second id is contained in both in the second and in the third path; this only can happen if the user is a Promoter.

I would like another field which counts how many times each id is contained in all paths (beside itself); so it should be 0 if the user is not a promoter and >0 if it is.

 

ID|isPromoter|

path |

children |

aaa-111-000 | false |

sqe-432-w14/2aq-4ec-t66/aaa-111-000/ |

0 |

sss-342-r34 | true |

a3e-543-1sd/34d-245-svt/s3a-bnj-klo/sss-342-r34/ |

3 |

hhy-e90-y7u | false |

a3e-543-1sd/34d-245-svt/s3a-bnj-klo/sss-342-r34/hhy-e90-y7u/ |

0 |

... |... |

... |

... |

I know that there is the function Text.Contains([path],[id]) but it is only true for the current row. I don't know how to do the count for all rows

1 ACCEPTED SOLUTION
fabiomanniti
Helper III
Helper III

I figured it out by myself

 

I added a custom column and this is the code

 

 

if [ispromoter] = 1
then List.Count(List.FindText(#"PriorName"[path],[id]))-1
else 0

View solution in original post

1 REPLY 1
fabiomanniti
Helper III
Helper III

I figured it out by myself

 

I added a custom column and this is the code

 

 

if [ispromoter] = 1
then List.Count(List.FindText(#"PriorName"[path],[id]))-1
else 0

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.