Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

How to add a row while comparing two date fields ?

utkarsh26
5 - Atom

I have the below data with me:

 

NameRequest StatusStart DateEnd DateStart Date2
ABC411/21/202311/22/202311/15/2023
ABC311/23/202312/1/202311/15/2023
ABC612/4/202312/5/202311/15/2023
ABC712/6/202312/7/202311/15/2023
ABC612/8/202312/12/202311/15/2023
ABC712/13/202312/13/202311/15/2023
ABC412/14/202312/15/202311/15/2023
ABC1412/18/202312/18/2023

 

 

11/15/2023

 

Now, I need to compare the Start date column with Start Date2 column as:

 

if Start Date2 < min(Star Date), add 1st row as below:

 

 

 

NameRequest StatusStart DateEnd Date
ABC"Not Available"11/15/202311/20/2023
ABC"4"11/21/202311/22/2023
ABC"3"11/23/202312/1/2023
ABC"6"12/4/202312/5/2023
ABC"7"12/6/202312/7/2023
ABC"6"12/8/202312/12/2023
ABC"7"12/13/202312/13/2023
ABC"4"12/14/202312/15/2023
ABC"14"12/18/202312/18/2023
3 REPLIES 3
Hammad_Rashid
11 - Bolide

To achieve this in Alteryx, you can use the following steps:

 

  1. Sort Tool:

    • Sort your data based on the "Start Date" column in ascending order.
  2. Formula Tool:

    • Create a new column named "Start Date2_Flag" using the formula:
      [Start Date2] < Min([Start Date])
      This will give you a True/False flag indicating whether "Start Date2" is less than the minimum "Start Date."
  3. Filter Tool:

    • Filter your data to keep only the rows where "Start Date2_Flag" is True.
  4. Union Tool:

    • Use a Union tool to combine the filtered data with the original data. Ensure that the columns match.
  5. Formula Tool:

    • Create a new column named "Request Status" using the formula:
      IIF([Start Date2_Flag], "Not Available", [Request Status])
      This will replace the "Request Status" with "Not Available" for the rows where "Start Date2_Flag" is True.
  6. Select Tool:

    • Choose the columns you want to keep in your final output.

The workflow above will add the required rows with "Not Available" in the "Request Status" column based on the condition you specified. Ensure that the column names and data types match between the original and filtered data to successfully perform the union.

Raj
16 - Nebula

Please find attached.
mark done if the solve your problem

CoG
14 - Magnetar

Here is a sample workflow that should accomplish what you're looking for:

_Main.png

Labels
Top Solution Authors