We help IT Professionals succeed at work.

Blank Optional DateRange omits Null Date values

Hillary B
Hillary B asked
on
193 Views
Last Modified: 2017-07-08
This is very close to many other topics but not quite what I'm looking for.

I have an Optional date range param that is set up like this in my record selection.
(not(HasValue({?DateRange}))) OR ( isnull({Table.Date}) or {Table.Date} in {?DateRange} )

When the date range is entered, it runs records within that range as well as NULL dates. This works fine.
However, when the range is left blank, it only runs for non-NULL dates. If the date value is null, it get omitted from the results.

I have tried:
if HasValue({?DateRange}) then
   isnull({Table.Date}) or {Table.Date} in {?DateRange}
else true

As well as:
if HasValue({?DateRange}) then
   isnull({Table.Date}) or {Table.Date} in {?DateRange}
else
     isnull({Table.Date}) or not(isnull({Table.Date}) )


What can I do to get NULL dates when the param is left blank?

Thanks
Comment
Watch Question

Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
Is that the complete record selection formula?
If not please provide the full formula (preferably copy and paste it).

mlmcc

Author

Commented:
The rest of the selection formula is just handling a few other optional parameters.

Here's the actual code... short and sweet.
(not(HasValue({?Name})) OR {Provider.Name} = {?Name} ) and
(not(HasValue({?Dept})) OR {Facilities.Department} = {?Dept} ) and
(not(HasValue({?Status})) OR {Facilities.Status} = {?Status} ) and
(not(HasValue({?DateRange})) OR ( isnull({Facilities.RetroDate} or {Facilities.RetroDate} in {?DateRange} ))

I've used this method for an optional date range param before with no problem but those reports dealt with data that always had a date value so NULL dates weren't an issue. This particular report I've had to modify for possible NULL dates and those blank dates will only display if the date param is filled in but not when left blank.

Thanks again.
CERTIFIED EXPERT

Commented:
This is probably a typo, but you don't have a closing ) on the IsNull for RetroDate.  If that is a typo, could you actually copy the formula from the CR formula editor and paste it in a post here (as mlmcc suggested), so we know that we're seeing the correct formula?

 Apart from that apparent typo, I don't see anything wrong with the formula that you posted, but if there's one mistake, there could be others.

 James
Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
Try changing the last line to

(not(HasValue({?DateRange})) OR  isnull({Facilities.RetroDate}) or {Facilities.RetroDate} in {?DateRange} )

ANother idea would be


(isnull({Facilities.RetroDate}) OR not(HasValue({?DateRange}))  or {Facilities.RetroDate} in {?DateRange} )

I see there are multiple tables, Is the Facilities table the main table?

mlmcc
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
Yeah, I don't see why the other formulas didn't work either.  I guess you can accept your last post as the solution.

 James