Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Help with Formula Regarding 7 Columns Null/True/False

Hello!
I have been trying to write a code in Power Query that allows me to have a custom column that comes back with either true or false If all of the columns selected in a row are nulls. I know I can do it in regular excel for two Columns with the formula: = (A1&B1)="" but I want to see if I can do this all in Power Query.

This is one of the MANY codes I've tried to run to allow a column to show True/False if all of the columns have nulls... Only Problem is it shows as a List and I'm not sure how to change that without making another Query? This only shows 2 columns but I want it to grab from a range (Something else I am struggling to figure out)
= Table.AddColumn(#"Renamed Columns", "TF", each {if (([#"TEST1"]&[#"TEST5"])=null) then true else null=false})

Essentially my data is for tests to ensure my products are up to par. It's rare but there are times we have to test products/tweak them more than once in order to ensure we get the right results. I figured if I could make a T/F column I could filter out the Falses (all rows containing only nulls) and use True if there is even one test in the multiple columns that may need to be ran more than once in order to prevent any loss of data. Only other issue is for this data set, the first 3 columns are for the batch number, date is was completed, and how many times a test needed to be ran to get desired results.

  • AlienSx's avatar
    AlienSx
    2 years ago

    Anonymous do you really have nulls? I've dropped first 3 columns:

    Table.AddColumn(
      #"Renamed Columns", 
      "TF", 
      (x) => List.MatchesAll(List.Skip(Record.FieldValues(x), 3), (y) => y = null)
    )

7 Replies

  • Hello, Anonymous 

    Table.AddColumn(
      #"Renamed Columns",
      "TF",
      (x) => List.MatchesAll(Record.FieldValues(x), (y) => y = null)
    )
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hello AlienSx 
    I entered in the formula exactly how you had it and also tried to add the first column of the range in for (y) and the last for the y but it is showing Falses even for rows that have data in every column unfortunately.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Here is an example I want of my data/what I want it to do if this helps anyone.

    BatchDateRepetition of TestsTest1Test2Test3Test4Test5Test6True/False

    100

    8/20/23

    150.555.855.800.50.88True
    1008/20/232 55.8    True
    1008/20/233      False
    1008/20/234      False
    1008/20/235      False
    1019/05/23150.455.855.800.40.86True
    1019/05/232      False
    1019/05/233      False
    1019/05/234      False
    1019/05/235      False

     

    • AlienSx's avatar
      AlienSx
      Super User

      Anonymous do you really have nulls? I've dropped first 3 columns:

      Table.AddColumn(
        #"Renamed Columns", 
        "TF", 
        (x) => List.MatchesAll(List.Skip(Record.FieldValues(x), 3), (y) => y = null)
      )
      • Anonymous's avatar
        Anonymous
        Not applicable

        I do have nulls. Entered this in and it worked. 
        Do you know if there is a way to hide this True/False column now that I can filter out the rows with all nulls?
        AlienSx