Hello,


I am trying to filter an aggregate based on a list of values. I have a list of a structure defined as:

  * Text

  *Boolean

when the boolean is true, I would like to filter base on the value, but right now, I cannot do that.

right now its only looking at current values:

Any help is appreciated.

Hey there,


Can you attach your oml, or a screen shot of your query, and  structure?

Hi Vinicius,

How do you are iterating the list, if you are using a variable list in a foreach, you can use an if statement with the values used in your example, Hope this help you,

Regards.


Hi Vinicious,

Creating a string with all the selected names separated by comma's and than use a advance query with IN statement is a good way of solving your problem.

Regards,

Marcelo

Can you provide an oml please? i think you need a foreach in the first list and then a listFilter widget in the second list wherer you compare if the current value of the mail list exists in the second list. If it does then you or move it to another temporary list or add a flag to that value.

Carlos Gonçalves wrote:

Can you provide an oml please? i think you need a foreach in the first list and then a listFilter widget in the second list wherer you compare if the current value of the mail list exists in the second list. If it does then you or move it to another temporary list or add a flag to that value.

Yes I think this seems like a possible solution. The solutions above mentioned a query, but I already have an aggregate that I would like to filter by that list (that already exists). Now, right now I have 2 for loops, one of them assigns true of false based on the selection, the other assigns the actual values (since the list was showing empty). Do I need a third, different for loop to assign it to a variable where only the ones with TRUE are selected? And if so, Now I'll have a list of text, how would I filter that in an aggregate, since that was the original issue.


Thank you all.


there is a widget call list filter that u pass a List, and a condition and it will create a list where the condition is true.


Have you tried use that?


To add List Filter to you Module you need to go Manage Dependencies / (System) / Server Actions / List Filter.


To help you more it would be nice if you could provide a simple oml with that Code you have there.



I will try that, right now I was manually doing that, and it worked, but let me try that. Once it is a list of concatinated strings, how can I filter that IN THE AGGREGATE? 

I unfortunally cannot provide the OML since it has sensitive information. 

Vinicius Seixas wrote:

I will try that, right now I was manually doing that, and it worked, but let me try that. Once it is a list of concatinated strings, how can I filter that IN THE AGGREGATE? 

I unfortunally cannot provide the OML since it has sensitive information. 

when when we ask for a sample i dont need it to it to be publishable you can just copy that code you have up there to an empty module save and send the oml with that.


I dont really understand what do u mean by filtering that in the aggregate since what you should to is use the list filter or a double loop where you use the AGGREGATE as the main loop and check if the value exists in the list of concatinated strings.


I am not sure if this is what you need. If not please explain in a different way what you need to accomplish.


BR

I have attached a basic module with the action that I am working with. The list filter you described is actually just returning me a list of the items that had TRUE for their boolean, which is cool, but here's the thing.

I currently have an aggregate with several filters that are already set up. I wished to include an extra filter to it, which filtered based on the items on that list. I couldn't find a way to do that. I have an aggregate, and a list, and I need to filter the AGGREGATE to only display the entries which contain the attributes in that list.

Thank you once again for all of your help!

For example, I have a list of stores, but I cannot use something like IN (that would be used in a query):

Mydatabase.name IN ( LIST HERE ).           or even

Mydatabase.name exists( LIST HERE).


Solution

Here i made some comments to help you understand.


I hoep this helped.

Solution

I think I understand what you did, but in the end I just end with a brand new list, that is formatted like an aggregate, but is not an aggregate...

Over here in the end you just made another list, that, yes is filtered like that, but I also had multiple filters in the aggregate like I mentioned before, and those were lost in the process. Instead of filtering the list like that with a for loop, there is no way to just compare the current, existing aggregate to a list and filter it in the *filter* function of the aggregate? Because if so, then there doesn't seem to be a solution to the problem.

Thank you for your help once again.

Hello Vinicius


After get a concatenated list, the best is use the Marcelo suggestion  using a IN clause on one advanced query.


Regards

Is there a way to transform that power query in an aggregate that I can use then?

Vinicius Seixas wrote:

I think I understand what you did, but in the end I just end with a brand new list, that is formatted like an aggregate, but is not an aggregate...

Over here in the end you just made another list, that, yes is filtered like that, but I also had multiple filters in the aggregate like I mentioned before, and those were lost in the process. Instead of filtering the list like that with a for loop, there is no way to just compare the current, existing aggregate to a list and filter it in the *filter* function of the aggregate? Because if so, then there doesn't seem to be a solution to the problem.

Thank you for your help once again.

when i did  that snipet of code i had the assumption that:


1. the aggregate is already filtered with all that things you tell me before

2. The AGGREGATE you are talking about is a list that is returned by an Aggregate Query

2. you will use the AGGREGATE as the final list.


with that in mind all the filtering i did was assigned to the AGGREGATE.

That assign i did in the end is exacly the list you have in the beguin but now has been filtered with the other list.


Carlos Gonçalves wrote:

Vinicius Seixas wrote:

I think I understand what you did, but in the end I just end with a brand new list, that is formatted like an aggregate, but is not an aggregate...

Over here in the end you just made another list, that, yes is filtered like that, but I also had multiple filters in the aggregate like I mentioned before, and those were lost in the process. Instead of filtering the list like that with a for loop, there is no way to just compare the current, existing aggregate to a list and filter it in the *filter* function of the aggregate? Because if so, then there doesn't seem to be a solution to the problem.

Thank you for your help once again.

when i did  that snipet of code i had the assumption that:


1. the aggregate is already filtered with all that things you tell me before

2. The AGGREGATE you are talking about is a list that is returned by an Aggregate Query

2. you will use the AGGREGATE as the final list.


with that in mind all the filtering i did was assigned to the AGGREGATE.

That assign i did in the end is exacly the list you have in the beguin but now has been filtered with the other list.



That makes a lot of sense now. So that is essentially changing the aggregate itself and saving it to its list. 

I tried that, and it crashed somehow. I can upload the OML with my implementation, but essentially I changed the AGGREGATE that you wrote to my aggregate's name and other fields to the fields I had. 

Did I do anything wrong?


Best,

V.S.

Yes, you can do this both with an Aggregate (at some extent) and with SQL.
Attached an example (with some limitations) for both:

Notice that for the example to work with SQL, it need the correct number of ' and , (like I did in the example), but the same is not needed for the Aggregate.

Here is the filter I used inside the Aggregate: 

But be warned: this is VERY inefficient

Prefer the SQL solution like Marcelo said at the beginning.

Cheers.

Vinicius Seixas wrote:

That makes a lot of sense now. So that is essentially changing the aggregate itself and saving it to its list. 

I tried that, and it crashed somehow. I can upload the OML with my implementation, but essentially I changed the AGGREGATE that you wrote to my aggregate's name and other fields to the fields I had. 

Did I do anything wrong?


Best,

V.S.

For this you need to debug the code and see where it call the exception.

To see what you need to fix.

The snipet i sent you had bad naming because i do not know what is the names of you lists so you need to adapt my code to you needs. Its important you understant what each part of that code do.


Carlos Gonçalves wrote:

Vinicius Seixas wrote:

That makes a lot of sense now. So that is essentially changing the aggregate itself and saving it to its list. 

I tried that, and it crashed somehow. I can upload the OML with my implementation, but essentially I changed the AGGREGATE that you wrote to my aggregate's name and other fields to the fields I had. 

Did I do anything wrong?


Best,

V.S.

For this you need to debug the code and see where it call the exception.

To see what you need to fix.

The snipet i sent you had bad naming because i do not know what is the names of you lists so you need to adapt my code to you needs. Its important you understant what each part of that code do.


I have debugged it. It crashed when I removed the previous filtering for just 1 store. I fixed the crash (it was dividing by 0 somewhere). 


The problem was that the condition needed to be 2 conditions : if the names matched and if the isSelected was true. I think it worked now. 


Thank you all for your solutions. I appreciate you all.

Vinicius Seixas wrote:

I think I understand what you did, but in the end I just end with a brand new list, that is formatted like an aggregate, but is not an aggregate...

Over here in the end you just made another list, that, yes is filtered like that, but I also had multiple filters in the aggregate like I mentioned before, and those were lost in the process. Instead of filtering the list like that with a for loop, there is no way to just compare the current, existing aggregate to a list and filter it in the *filter* function of the aggregate? Because if so, then there doesn't seem to be a solution to the problem.

Thank you for your help once again.

Hi Vinicius Seixas , What type of the information stored in assign widget , Could you please show this ?