Link to home
Start Free TrialLog in
Avatar of Hillary B
Hillary B

asked on

Blank Optional DateRange omits Null Date values

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
Avatar of Mike McCracken
Mike McCracken

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

mlmcc
Avatar of Hillary B

ASKER

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.
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
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
ASKER CERTIFIED SOLUTION
Avatar of Hillary B
Hillary B

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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