Data table filter _Date

Sheet.xlsx (9.6 KB)
Hi Team,

I have input data table mentioned in sheet.xlsx and in Visit_Date.xlsx
Visit_Date.xlsx (8.4 KB)
Sheet I have another data table.

I have to filter the dates as mentioned in the input dt.

Also for 05/16/2023 there is 2 line items are there, From that I need to get only the row 2

Kindly help me out to solve this problem

Thanks in Advance

Here’s a comprehensive workflow that addresses your needs:

  1. Read Excel Data:
  • Use the “Excel Application Scope” activity to open both Excel files:
    • For sheet.xlsx: Read the entire table into a data table variable named dt.
    • For Visit_Date.xlsx: Read the entire table into a data table variable named visitDatesDT.
  1. Filter Dates:
  • Use the “Filter Data Table” activity to filter dt based on the Visit_Date column:
    • Expression: dt: "Visit_Date".ToString == visitDatesDT("Visit_Date").ToString
    • This expression ensures case-sensitive matching of dates across both tables.
  1. Select Row 2 for 05/16/2023 (Optional):
  • If you specifically need the second row for 05/16/2023:
    • After filtering, use an “If” activity:
      • Condition: FilteredDT: "Visit_Date".ToString == "05/16/2023" (replace FilteredDT with the output name of the “Filter Data Table” activity)
      • Then: Assign the second row (FilteredDT: 1) to a new data table variable (e.g., row2DT).
      • Else: Use the entire filtered data table (FilteredDT) if the date condition isn’t met.
  1. Process the Filtered Data:
  • After filtering or selecting the specific row, you can use the resulting data table(s) for further processing in your automation. You can iterate through the rows, perform calculations, or write them back to another file as needed.

UiPath Workflow Example (Assuming FilteredDT is the filtered data table):

`XML

<Filter DataTable=“[dt]” FilterRows=“dt.ToString == visitDatesDT(“Visit_Date”).ToString” Result=“[FilteredDT]”>

<If Condition=“FilteredDT.ToString == "05/16/2023"”>


row2DT
FilteredDT



"Visit_Date: " + [Row]("Visit_Date").ToString

`

content_copy

Explanation:

  • The code reads both Excel files and stores the data in data tables.
  • The “Filter Data Table” activity performs case-sensitive date filtering.
  • The optional “If” activity selects the second row for a specific date if needed.
  • The final part (replace with your logic) demonstrates iterating through the filtered data for further processing.