Need helps with creating if condition

Good morning,

I am working on a project where the Bot is going to pull information from excel spreadsheet and create a document in a web.
The problem I am facing is how to get the Bot to create a new document number when the “Title” is different.
What is my “If” condition should look like?
Thank you,

image

Hi @Khanh_Nguyen,

Few questions and inputs as below to try:

  1. Are these titles going to be in ascending/descending order?
  2. If same titles will appear in a sequence only, then within a loop, you can do comparison with previous title. If both are equal, no need to generate new document number. If different, then generate new document.
  3. If titles will not appear in a sequence, then it would be worthwhile to first sort your list by title so all same entries appear together.

Regards
Sonali

Hi Sonali,

The Bot should create one document number for each “Title” and each “Title” will have one or two lines, dependent on the the number of betterment/amount.
For example:
Title EP12345, the Bot should create one document but the document should have two lines. First line for $6,762.00 and second line is for $65,870.01

Tittle EP00002, the Bot should create one document and the document should have only one line for $839,428.00.

The problem I have right now is when I run the Bot, it created one document for Title EP12345, then it created two lines of account as it should but it does not stop there, it would continuing to create a third line for $271,754.40 that belong to Title EP00001.
I need the Bot to stop after created line two of Title EP12345. Then the Bot should create a NEW DOCUMENT for Title EP00001 with two line; First line for $271,754.40 and second line for $5,000.00. Then create another new document for Title EP00002 with one line.

Thank you,

@Khanh_Nguyen - Here you go…This is my final output…where you can see 3 txt files created with the requirement as you mentioned…

image

My Input → I called this as Dt , Dt is datatable variable…

Then Clone the dt and call it as DtAgg , DtAgg is a datatable variable…

    DtAgg = (From d In dt.AsEnumerable
             Group d By k=d("Title").toString.Trim Into grp=Group
             Let el = String.Join(";"c, grp.Select(Function (x) x("Amount").toString.Trim))
             Let ra = New Object(){k, el}
             Select DtAgg.Rows.Add(ra)).CopyToDataTable

For Each Row…of the DtAgg…

Append Line Code

string.join(vbcr,CurrentRow("Amount").ToString.Split({";"c},StringSplitOptions.RemoveEmptyEntries))

 CurrentRow("Title").ToString + ".txt"

I checked my intermediate output…which is correct…

image

Please follow the steps as mentioned above.

Hope this helps…

Thank you Guru. I been working on this over two weeks now but has no luck. Let me try out your processes. Once again. Thank you.

Sure. Let us know, if you need any assistance.

Good morning Guru,

It didn’t work as I hope it would be. I thinks because my workflow required that I use the data in the excel sheet (Title, Betterment and Amount) to be enter into the web form.
How would you change your workflow? Do you need to modifies the second Assign?
Thank you,

Khanh

@Khanh_Nguyen -When you said “It didn’t work” , you have to show us what you have tried and what is the error? Without that details how can we assit further…please always show the screenshot of your workflow along with the error…

Is it possible to share the sample sheet (after masking sensitive info)?

Also, use “Reply” icon when you are replying to this post OR use @ symbol and tag my name if not i will not get notification…

image

@prasath17 - Hi Guru, please see my workflow.

  1. Log in to the Web
  2. Read the excel sheet
  3. Input data from the excel sheet to the Web system to create a document #
  • Title EP12345 have two different amount, therefore the document will have two lines within it.

The problem I trying to solve is to have the Bot stop after completed created line 2 for Title EP12345. Next the Bot should go and create a new Doc# for Title EP00001 and the two line of information it have.

Right now base on my workflow the Bot does not stop after completed line 2 of Title EP12345 but it continuing to pull information from Title EP00001 and created a third lines, which it should not do.


Please see the incorrect result below. Line $271,754.40 should not be there. It should go to a new Document in Title EP00001.
image
Thank you,

Khanh

@Khanh_Nguyen - Please find the workflow attached…Please remove the build datatable activity and replace it with Read Range. Aggregate.xaml (9.6 KB)