For each row club together by row item

Hello together,

I am new in the community and I am facing an issue, maybe you can help me.
I want to iterate through a data table and order items in an online shop (amazon).

I want to club the orders by brands. And I want to create a shopping basket for each brand.
In the example, I want the shoes, trousers and shirts from nike in a shopping basket and after I ordered that basket, I want to shop the next one with shoes and shirt from adidas and so on.

2020-03-11 15_23_38-Mappe1 - Excel

How can I iterate through the table AND do the actions for each brand? I already sorted data table, but that was not enough.

Many thanks in advance and
Best regards

Are you looking for something that looks like this?

image

@jonasghost

I would suggest that you filter your data first, than iterate throught the table… :point_down:

Example :

ExtractDataTable = ExtractDataTable.select("[article]"= 'shoe'").CopyToDatatable
1 Like

That is just the sorted table. So far so good. Now I want to do actions (grab article from each row) and place an order for each brand. Something like "if next row is same brand, then put it in same order basket, if not, then create a new basket.

Hi, that is a good idea, but can I say “after you filtered for the brand nr.1, filter then for brand nr.2 and do the same process, until all open positions are ordered?”

1 Like

@jonasghost

Well, you can use a switch :point_down:

The Switch Activity

To do so use variables on the filter so that it become dynamic and use the switch… :point_down:

ExtractDataTable = ExtractDataTable.select("[VarArticle]"= VarProduct).CopyToDatatable

Actually, it is not going so well using the switch.
I don’t know how to use the switch correctly.

In this example, I would like to receive 3 datatable (for each brand), so I can proceed with the “filtered” information. Nevertheless, I am not able to create a dynamic filter.

Could you give me a hint?
Switch Test DB.xaml (11.4 KB)

1 Like

@jonasghost
Have a look on this demo xaml
jonasghost.xaml (9.5 KB)

1 Like

Thanks, that is a brilliant result.

Is it possible, to create for each brand a new datatable? (with information artivcle, qty, brand)

One question regarding your assign dialoge: what does the “r” mean? Is it from “right”?
And what does the term “b=r(“brand”)” mean?

(From r In DtTable
Group r By b=r(“brand”).toString.trim Into grp=Group
Select grp.toList).toList

@jonasghost
have a look on this variation:
jonasghost_V2.xaml (10.8 KB)

r is like a local variablename for the linq statement and is representing the current looped row
we define the grouping by using the brand column value and assign it to an identifier called b

https://www.tutorialsteacher.com/linq/linq-grouping-operator-groupby-tolookup

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.