Filter list for unique values

3
Hi all, I would like to populate a data grid with a microflow. Here is the setup: There is an entity "WarehouseTransaction". One attribute of the transaction is "Location". There are several transactions/records with the same location. I would like to create a list where each location is included only once. In other words: I would like to remove all "duplicate locations". I have tried the list operation "union", but could not make it work. Any suggestions are welcome
asked
5 answers
5

Union means that it will combine two lists. Not exactly what you want. . There is no list operation for this as far as I know

  1. Create a new list: warehousetransactionsUniqueLocations
  2. Loop thru the warehousetransactions
  3. in the loop: add a list operation 'find' equals IteratorWarehouseTranaction/Location
  4. If not found: add to the warehousetransactionsUniqueLocations list.
answered
1

This sounds like a situation where data normalization would help you. You should create a Location entity to store your location, then associate each WarehouseTransaction to a Location.

To accomplish this, you could loop over the WarehouseTransaction entity, try to retrieve a Location with the same value, and it you cannot find one, then create it.

answered
1

Tim,

I read your question a couple of times before it occurred to me that if you want to source a datagrid with Location, you must have a Location entity. If you don't have one yet, you'll need one in order to have a datagrid of locations.

So lets assume you have created Location, and have a 1 to many association between Location and WarehouseTransaction (each Location can have many WarehouseTransactions, but each WarehouseTransaction can have only 1 Location). Lets also assume that this is populated as Eric describes in his answer. If you retrieve Location and use an XPath that limits the retrieve to a set of WarehouseTransactions, the Retrieve will return a unique list of Locations. For instance, lets say WarehouseTransaction has a transaction date, and your retrieve has an XPath that limits the Location to only those transactions that occurred in October 2015 (via the association between Location and WarehouseTransaction), the resulting list will contain the unique Locations that had a transaction in October.

Hope that helps,

Mike

answered
0

Try the list function filter: https://world.mendix.com/display/public/howto50/Working+With+Lists+in+a+Microflow#WorkingWithListsinaMicroflow-6.FilterListofOrdersontheCityoftheAssociatedCustomers

Regards,

Ronald

answered
0

Hi all, 

I tried to solve it like it is described above, but I'm missing something and don't know where and what. 

Set-up: 

- One entity with a few attributes. MachineID, TransactionID (see picture) etc.. Some records have the same MachineID and I want to delete the duplicated records and after that, count all that records with the unique Machine ID.

- I have the following Microflow.

 

Thanks

answered