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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
BeLocke
Frequent Visitor

Check for character repetition

I am attempting to create a column that checks for character repetition and returns True or False. The value column is made up of sentences. Below is a record of what a fail record in the value column would look like.

 

My name is ibrahim ghazi mohammed al barqi im fresh graduated from king khaled university. This course will help me to get a jop gdh hshd jdjd jdjd jdid j i i i j i i i i j i i i j j j i i i i j i i i i j j j j j j j j jj j j j j jj j j j j j j jj j j j j j jj j j j jj j j j j j j j j j j jj j j j j

2 ACCEPTED SOLUTIONS
ZhangKun
Super User
Super User

If you mean to check for repeated words, you can split the sentence based on spaces and then check the number of items in the original list and after removing duplicate values.

let 
    a = Text.Split([value], " ") 
in 
    List.Count(a) <> List.Count(List.Distinct(a))

 

View solution in original post

Anonymous
Not applicable

Hi @BeLocke ,

 

Thanks for your reply.

Well I think ZhangKun's method is good.

Here's an example based on his code.

let
            words = Text.Split([value], " "),
            distinctWords = List.Distinct(words)
        in
            List.Count(words) <> List.Count(distinctWords)

vstephenmsft_1-1732779603157.png

However, I noticed that you want to start with the fourth word of each row of text and check if there are any words repetition. Please use the following code:

let
            text = [value],
            words = Text.Split(text, " "),
            wordsToCheck = List.Skip(words, 3),  
            distinctWords = List.Distinct(wordsToCheck)
        in
            List.Count(wordsToCheck) <> List.Count(distinctWords)

vstephenmsft_2-1732780211362.png

 

Best Regards,

Stephen Tao

 

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

6 REPLIES 6
Anonymous
Not applicable

Hi @BeLocke ,

 

Did the above replies help you? If so, please accept them.

If not, I need to make sure, do you expect the result below to be what you want?

The third row repeats "a" twice, so it returns false, and the second row doesn't repeat the letter, so it's true.

vstephenmsft_0-1732611392070.png

If the logic of the return result is not like this, please provide an explanation, thank you. Looking forward to hearing from you.

 

Best Regards,

Stephen Tao

 

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

 

No, these replies are not quite what I am looking for. I need to clarify my question. I am looking for word repetition, preferably after three words. I'm looking at application data and want to check the applicants' adding filler to make the paragraph longer. 

Anonymous
Not applicable

Hi @BeLocke ,

 

Thanks for your reply.

Well I think ZhangKun's method is good.

Here's an example based on his code.

let
            words = Text.Split([value], " "),
            distinctWords = List.Distinct(words)
        in
            List.Count(words) <> List.Count(distinctWords)

vstephenmsft_1-1732779603157.png

However, I noticed that you want to start with the fourth word of each row of text and check if there are any words repetition. Please use the following code:

let
            text = [value],
            words = Text.Split(text, " "),
            wordsToCheck = List.Skip(words, 3),  
            distinctWords = List.Distinct(wordsToCheck)
        in
            List.Count(wordsToCheck) <> List.Count(distinctWords)

vstephenmsft_2-1732780211362.png

 

Best Regards,

Stephen Tao

 

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

 

 

 

Omid_Motamedise
Super User
Super User

If your desired character you want to count is x, use the below formula

 

 

Text.Length([column])- Text.Length(Text.Replace([column],"x"))

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h
ZhangKun
Super User
Super User

If you mean to check for repeated words, you can split the sentence based on spaces and then check the number of items in the original list and after removing duplicate values.

let 
    a = Text.Split([value], " ") 
in 
    List.Count(a) <> List.Count(List.Distinct(a))

 

rohit1991
Super User
Super User

Hi @BeLocke 

 

Here's the direct M code to check for character repetition in Power Query:

        1. Go to Power Query Editor: Home >> Transform Data >> Transform Data.

        2. Add a Custom Column:

             a. Click Add Column >> Custom Column.

             b. Use this formula:              

if Text.Contains([value], Text.Repeat("j", 3)) or Text.Contains([value], Text.Repeat("i", 3)) then true else false.

             c. Adjust for Other Repetitions (Optional):

                    i. Replace "j" or "i" with the characters you want to check.

        3. Save and Apply:

             a. Click Close & Apply to return to Power BI.


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

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