Replace Null Values with Randbetween

  • Replace Null Values with Randbetween

    Posted by DSC Communities on September 15, 2018 at 10:39 am
    • Allan Blain

      Member

      September 15, 2018 at 10:39 AM

      I know this should be easy but ……… I have a date column that should be filled in and is empty and the query returns null. I’d like to use the replace null function in the query editor to replace the nulls with random dates between today and some future date. When I try adding the power query formula I get an error message asking me to enter a specific date.

      ——————————
      Allan Blain
      Project Manager
      Portland OR
      2052135310
      ——————————

    • Del Swingle

      Member

      September 15, 2018 at 4:22 PM

      Allan,
      As a suggestion, you could create a new custom column that looks at the original Date column and use an if statement similar to the following:

      Ā if [Date]=null then
      Number.RandomBetween(Number.From(DateTime.LocalNow()),Number.From(Date.AddDays(DateTime.LocalNow(),365)))
      elseĀ  [Date]

      This will look for any nulls in you Date column and generates random date between today and 1 year from now and copy any values not null. This will return a date serial number so you’ll need to convert this new column to type date.

      Hopefully this helps,

      ——————————
      Del Swingle
      WA
      ——————————
      ——————————————-

    DSC Communities replied 6 years, 11 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

The discussion ‘Replace Null Values with Randbetween’ is closed to new replies.

Start of Discussion
0 of 0 replies June 2018
Now

Welcome to our new site!

Here you will find a wealth of information created for peopleĀ  that are on a mission to redefine business models with cloud techinologies, AI, automation, low code / no code applications, data, security & more to compete in the Acceleration Economy!