2194
Views
9
Comments
Use variable to filter aggregate

I have an Aggregate in an Action. 

Based on the value of an Action's Input Variable, I want to be able to filter the aggregate.

This way I will avoid creating multiple Aggregates based on the value of the Input Variable.

Is this possible? How can I do this?


Thanks a lot


Marios 

2020-02-28 09-46-54
Eduardo Jauch

Hello Mario,

You can use variables directly into an aggregate (if the aggregates can "see" the variable based on its scope).
This is shown in the online training...

Beware using aggregates in "Server actions", as the optimization will be shutting down if you return from it the list of the aggregate, as the platform can't know beforehand where the action will be used.

Cheers.

2023-07-28 17-00-32
Marco Arede
 
MVP

Hi Marios,

What content is the action input variable going to have? It's possible, depending on what you need.

Depending on the input you have, you can use advanced queries to do more advanced operations.

Regards,

2018-07-23 11-05-10
Marios Andreas Tofarides

Thanks, Eduardo,


I want to use a filter variable, in which I will create a condition for the Aggragate Filter based on the Input Variable. 

And then, use the filter variable in the aggregate filter.


 

2020-02-28 09-46-54
Eduardo Jauch

Marios Tofarides wrote:

Thanks, Eduardo,


I want to use a filter variable, in which I will create a condition for the Aggragate Filter based on the Input Variable. 

And then, use the filter variable in the aggregate filter.


 

In general, yes, you can do it without problem.
Are you new to Aggregates?

If so, I recommend you to take a look in the online training to get familizarized with it, and check the online documentation that Marco pointed.

An aggregate can have filters and in the filters (as well as in the join clauses), you can use "external" variables (declared in the page or in the action the aggregate is).

Cheers.


2018-07-23 11-05-10
Marios Andreas Tofarides

Eduardo and Marco,


I've done aggregated before, but not dynamic filters in an aggregate. I'll check what you posted.


thanks a lot!


Marios

2025-04-22 05-54-18
Shashi Kant Shukla

Hi Marios,

You can do the dynamic filter using variable in aggregate like below where EmployeeNumber is InputParameter of action.




Regards

-SK-

2018-07-23 11-05-10
Marios Andreas Tofarides

Shashi, 


What I really want is to put that expression into an "EmployeeFilter" variable and then just type in the filter "EmployeeFilter"


Marios

2020-02-28 09-46-54
Eduardo Jauch

Marios Tofarides wrote:

Shashi, 


What I really want is to put that expression into an "EmployeeFilter" variable and then just type in the filter "EmployeeFilter"


Marios

Hello Marios,

You can't do that in an Aggregate.
For this type of "dynamic" filter, you will need a SQL statement, passing the condition as a Query parameter (set to expand inline).
But if you will give the user the ability to write the condition freely, I think he will also be able to inject SQL.

Cheers.


2018-07-23 11-05-10
Marios Andreas Tofarides

OK Eduardo,


Thanks a lot. I might try that. 


Marios



Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.