Forum Discussion

MStaford's avatar
MStaford
Regular Visitor
1 year ago
Solved

Case insensitive table.findtext across multiple columns

Hi All,

I have a situation where I have to bring across only those rows where a specific values specific value (lets say, "true")  appears in 5 selected columns with multiple files with each including over 200 to 400K rows.

 

Minimum rules - The "true" can be atleast in one column to qaulify the extraction of row.

 

Additionally, the text in the column inconsistent with some files has it uppercase and other have it in lowercase.

 

Following is the dummy dataset.

 

idbla1yaba2daba3lamadoo
1222truetruetruetruetrue
1233TRUETRUETRUETRUETRUE
1234TrueTrueTrueTrueTrue
1443TrueFalseTrueFalseFalse

 

I have tried the following formula to extract the rows however, it only extract rows where a lowercase or uppercase depending on the text case i have used in the argument.

 

table.IsEmpty(table.FindText(table.SelectionColumns([dataset],{"bla1", "yaba2","daba3","lama","doo"}),"true")) (or using "TRUE" OR "True")

 

Problem statement - is there anyway we can modify this formula to check for "true" ignoring the case? or is there anyother options i can use?

 

Additionally, I have tried to do data normalisation and a conditional column to allocate numeric marker (1,2,3,4,5) for each column if there is "true" values (0 for false) and filter the column with false value to condence the result . It works however, I have to load the data in power query and then normalise the data to upper or lowercase which is not favourable as combine total rows of these files can go over 20mil.

 

I feel i might be sailing close to the answer but unable to get my hands on it.

 

I hope someone can help me.

 

Thankyou in advance for your help and support 😊

 

  • Hi MStaford 

     

    Still using the same code  in my initital post but changing List.AllTrue to List.AnyTrue to check if at least one of the column values contains the word true..

    let
        // Step 1: Define a list of values, replace with the actual column names
        ColumnsAsAList = {[bla1], [yaba2], [daba3], [lama], [doo]},
    
        // Step 2: Convert each value in the list to a logical (true/false)
         ChangedType = List.Transform(ColumnsAsAList, Logical.From),
        // Step 3: Check if all values in the list are true. Use List.AnyTrue to return true if any of the values in the list  is true
        TrueOnly = List.AnyTrue(ChangedType)
    in  
       TrueOnly

5 Replies

  • Hi ryan_mayu 

     

    Try this custom  column in the query editor. Use List.AnyTrue to return true if any of the values in the list  is true

    let
        // Step 1: Define a list of values
        ColumnsAsAList = {[bla1], [yaba2], [daba3], [lama], [doo]},
    
        // Step 2: Convert each value in the list to a logical (true/false)
         ChangedType = List.Transform(ColumnsAsAList, Logical.From),
        // Step 3: Check if all values in the list are true. Use List.AnyTrue to return true if any of the values in the list  is true
        TrueOnly = List.AllTrue(ChangedType)
    in  
       TrueOnly
    

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi ,

    The method ryan_mayu provided should be helpful.

    Besides, you can also try the following formula to add the custom column.

    if Text.Contains([bla1], "true", Comparer.OrdinalIgnoreCase) or
       Text.Contains([yaba2], "true", Comparer.OrdinalIgnoreCase) or
       Text.Contains([daba3], "true", Comparer.OrdinalIgnoreCase) or
       Text.Contains([lama], "true", Comparer.OrdinalIgnoreCase) or
       Text.Contains([doo], "true", Comparer.OrdinalIgnoreCase)
    then "true" else "false"

     

    Best Regards,

    Wisdom Wu

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

  • MStaford's avatar
    MStaford
    Regular Visitor

    Hi danextian andryan_mayu,

     

    Thankyou for your reply and suggested solutions. The minimum condition for true value to be the result is that atlease one col should have a true value and only if all appears false then the result should be false. Apologies if i was not clear in my notes above. Here is a quick sample..

    Col1Col2col3col4col5Result
    truetruetruetruetruetrue
    truefalsetruefalsetruetrue
    truefalsefalsefalsefalsetrue
    falsefalsefalsefalsefalsefalse

     

    AnonymousI have not tried your method but will give it a go and come back.

     

     

    • danextian's avatar
      danextian
      Super User

      Hi MStaford 

       

      Still using the same code  in my initital post but changing List.AllTrue to List.AnyTrue to check if at least one of the column values contains the word true..

      let
          // Step 1: Define a list of values, replace with the actual column names
          ColumnsAsAList = {[bla1], [yaba2], [daba3], [lama], [doo]},
      
          // Step 2: Convert each value in the list to a logical (true/false)
           ChangedType = List.Transform(ColumnsAsAList, Logical.From),
          // Step 3: Check if all values in the list are true. Use List.AnyTrue to return true if any of the values in the list  is true
          TrueOnly = List.AnyTrue(ChangedType)
      in  
         TrueOnly