If statement in filter with Boolean condition

If statement in filter with Boolean condition

  

Hi there, 


I think I am missing something obvious here! I have a tick box that gives me a boolean input that I want to use in a filter for an aggregate (The boolean result is stored in DomainIsUnassigned). 

All I want to do is:

If DomainIsUnassigned=True: 

filter out all Company records that do NOT have a domainId (that is, Domain.Id=NullIdentifier()) . 

Otherwise, If DomainIsUnassigned=False: 

I want to simply return all company records (irrespective of whether or not they have a DomainId). The filter is given below: 


Company.DomainId=If(DomainIsUnassigned=True,NullIdentifier(),Company.DomainId)

However, if I apply this filter results are only returned if DomainIsUnassiged=False. 

Also, if I remove the ''If" statement and try only: 

Company.DomainId=NullIdentifier()  (only companies without domains are returned -as expected)

or, only: 

Company.DomainId=Company.DomainId: All records are returned (as expected).


So, I assume I am using the IF statement incorrectly? 


Kind regards,
Cole 


Solution

Hi Cole,


Your filter in the query should be:


DomainIsUnassigned = False or Company.DomainId=NullIdentifier().


The first condition ensures you don't filter anything if the boolean is False, otherwise it will filter for the companies with DomainId is null.


Hope it helps.

Solution

João Marques wrote:

Hi Cole,


Your filter in the query should be:


DomainIsUnassigned = False or Company.DomainId=NullIdentifier().


The first condition ensures you don't filter anything if the boolean is False, otherwise it will filter for the companies with DomainId is null.


Hope it helps.

Thanks a lot, João! :) Works a charm

If(DomainIsUnassigned,Company.DomainId-NullIdentifier(),1=2)

Or you could try this too...