19
Views
10
Comments
Solved
Enable or disable a Filter in aggregate
Question
Application Type
Mobile

I have an aggregate with a filter set against a variable "FilterVar".

I have a dropdown that can select a value for the "FilterVar".

Now, if i do not select a value to this FilterVar, i want to list all that is present in the aggregate. If i select a value for FilterVar, then i want to display only the data matching this result.

How can i implement this?

Solution

Hi Learn It,


The strategy is to have your condition to be written with an OR and one of the clause to be the FilterVar = its default value so to ignore the other condition.


If your filter is of type Text, set your filter to: FilterVar = "" or <YourOriginalFilter>.

If your filter is of type Number, set your filter to: FilterVar = 0 or <YourOriginalFilter>.

If your filter is of type Identifier, set your filter to: FilterVar = NullIndentifier() or <YourOriginalFilter>.


Example for a filter of a client id, if FilterVar = NullIdentifier() or Client.Id = FilterVar.


Regards,
João

Rank: #0

Thanks for the solution. I could filter it now. But one question, Since i am using a drop down to select the value of FilterVar . Once i select one parameter, then it cant be empty right. So if i want to go back and query all, how can i reset that?

Hope my question is clear

Hi Learn It,


I am glad I could help. Please consider, if it solved your problem, to mark the above answer as solution so other developers can find help if they run into a similar issue.

To reset it you just need to set the value of FilterVar variable back to the default value: NullIdentifier() if its type is Identifier, 0 if its type is integer, etc.

Rank: #0
Rank: #0

Hello Learn It,

Hope you're doing well.


What is the data type of your variable "FilterVar"?

Basically, your filter in the Aggregate should be something like:

FilterVar = NullIdentifier() or FilterVar = Aggregate.List.Current.Entity.Id


I am considering your FilterVar as an Identifier.


Kind regards,

Rui Barradas

mvp_badge
MVP
Rank: #0

Hi Learn It,

Such condition could be solved using the OR connector i.e.

Assuming the data type of FilterVar to be Text type


Filter Condtion:

trim(FilterVar) = "" or Entity.AttributeValue = FilterVar


Hope this helps you!


Kind regards,

Benjith Sam

Hii!

someting like :

Entity.var = FilterVar or FilterVar=""



Hello,

I am not sure if this would be possible into a single aggregate. So, I would suggest you to add 2 aggregates (with FilterVar and WithOut)FilterVar and apply an If condition to check, if FilterVar have some value execute the aggregate which is with "FilterVar" and if FilterVar is blank execute the aggregate which is without "FilterVar" filter. 

Thanks & Kind Regards,

Sachin

Hi Learn it,


Create a filter like this

Entity.variable = FilterVar or FileterVar = DefaultValue

hi Learn it

you can use conditional inside filter like that