+ Reply to Thread
Results 1 to 10 of 10

PQ problem with null value validation

  1. #1
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    PQ problem with null value validation

    Hi all

    I do a lot of validation, for instance checking if 2 columns are equal, and if not I list the differences in a conditional column. So lets say I have a table like below
    nullcheck0.png


    If Column1 and Column2 are not equal, I want to show content of Column1, Column2 and Column3 in a new Check column. I do that with this code for the Check column:
    Please Login or Register  to view this content.
    So this would be my expected result in that column:
    nullcheck1.png

    Problem is that if one of the columns I want to show content from contains a null, then it does not show anything as it all evaluates to null, see first row :
    nullcheck2.png

    How can I get the differences listed regardless of whether some of the columns contains a null?

    Bonus question: It seems PQ is not very consistant about nulls and blanks, when it comes to functions like merge etc. Some functions seems to be default null, while others are default blanks. This is also the case with different column types, like number and text. I was not aware of this, when I started using PQ, which means I now have a lot of different data, where some columns contains null, while others contain blanks. I realize that in some cases you do need to differ null from blank, but what are the general best practice about this - is it something like always replacing null with blank (or vice versa) after doing your steps, so data becomes consistant or is there another way of handling this?

    Best regards
    Imbizile
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    03-28-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    11

    Re: PQ problem with null value validation

    A simple solution is to select all the columns which could contain a null, then use the replace tool to replace null with a blank space (the value to replace is literally the word null)

    This appears to already have happened in the second entry in Column 3 in your screenshot, so doing the above will give your data consistency.

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,985

    Re: PQ problem with null value validation

    You could also just change the calculation to something like:

    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

  4. #4
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: PQ problem with null value validation

    Thanks for the suggestions.

    I will go with the last one

    Cheers

    Best regards
    Imbizile
    Last edited by Imbizile; 04-02-2021 at 06:04 AM.

  5. #5
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: PQ problem with null value validation

    Hi again

    I often put the column name in front of the result, like
    Please Login or Register  to view this content.
    But adding that to the last solution results in the same issue, where it totally skips the nulls. So with the below code, I would have expected it to return "1:Blue || 2:Green || 3:" in the first row in the Check column, but it only returns "1:Blue || 2:Green". Is there a way to include that in this solution?
    Please Login or Register  to view this content.
    nullcheck3.png

    Best regards
    Imbizile
    Attached Files Attached Files

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,673

    Re: PQ problem with null value validation

    You need this:

    Please Login or Register  to view this content.
    Last edited by AliGW; 04-12-2021 at 05:40 AM.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,985

    Re: PQ problem with null value validation

    You could also handle that inline like this:

    Please Login or Register  to view this content.

  8. #8
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: PQ problem with null value validation

    Please try dynamic columns PQ
    The same code when add more Column

    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    04-30-2010
    Location
    Denmark
    MS-Off Ver
    Office 365
    Posts
    215

    Re: PQ problem with null value validation

    Thanks again for the suggestions.

    The dynamic solution is very nice indeed and I think I can use that in other scenarios, but I often need to combine text from several specific columns, while leaving others out. The optimal solution would be to be able to point out specific columns, lets say i did not want Column2 to be included, so I only wanted Column1 and Column3.

    But I can work with the solution mentioned, using the if statement inline.

    Thanks again everyone

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,673

    Re: PQ problem with null value validation

    You may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Null validation cells help
    By abdullahsikandar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-12-2014, 10:38 AM
  2. [SOLVED] NULL (blank) problem
    By amt7565 in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 02-08-2014, 09:06 AM
  3. Input box validation for null value!
    By devpp in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-23-2013, 12:23 PM
  4. Validation list - not null
    By m.cain in forum Excel General
    Replies: 9
    Last Post: 06-27-2012, 04:56 PM
  5. if null, then formula problem
    By hrclark in forum Excel General
    Replies: 4
    Last Post: 10-17-2011, 11:29 AM
  6. [SOLVED] data validation and null text
    By Scarababau in forum Excel General
    Replies: 3
    Last Post: 03-31-2006, 09:40 AM
  7. IF IS NULL PROBLEM
    By Teri in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-25-2005, 05:06 PM
  8. IIF IS NULL Problem
    By scott in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-03-2005, 10:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1