Alteryx Designer Desktop Discussions

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

Question: Generate Rows within date ranges using multiple Condition Expressions

mahar0
Átomo

Hi

 

I have the following dataframe where date columns data type are YYYY-MM-DD

Idstart_dateend_date
1232023-02-012023-06-30
3452023-01-012023-12-31

 

I'm trying to use Generate Rows Tool to Generate 1st date of the month with conditions

  1. month should be less than equal to 2023-07-01
  2. month generated is greater or equal to 2023-03-01

The output that I'm expecting is

Idstart_dateend_datemonth
1232023-02-012023-06-302023-03-01
1232023-02-012023-06-302023-04-01
1232023-02-012023-06-302023-05-01
1232023-02-012023-06-302023-06-01
3452023-01-012023-12-312023-03-01
3452023-01-012023-12-312023-04-01
3452023-01-012023-12-312023-05-01
3452023-01-012023-12-312023-06-01
3452023-01-012023-12-312023-07-01

 

The current solution that we have is using Condition Expression month <= end_date with Loop Expression DateTimeAdd(month,1, 'month') then use Filter Tool to ignore the rows that we do not want, just wondering we can eliminate Filter Tool step to make the workflow more neater

 

Best Regards,

4 RESPUESTAS 4
AGilbert
Bólido

try this out.

 

Screenshot 2024-05-13 155031.png

mahar0
Átomo

Thanks for the IF statement. Unsure why the IF statement that you used didn't work in my Alteryx Designer (2023.2.1.89 Patch 2) but I managed to get it works by using the following syntax in Initialization Expression

IF [start_date] < [min] THEN [min] ELSE [start_date] ENDIF

 

AGilbert
Bólido

Good job troubleshooting! 

 

The statement I used is an IIF (2 I's) and it accepts three augments. The first is a true/false test, second is the value to return if the test = true, third is the value to return if the test = false. This does the same thing as your if statement and is a useful shorthand when expressions get longer. 

 

I'd be surprised if the IIF statement was not supported in the earlier release. 

flying008
Magnetar

Hi, @mahar0 

 

FYI.

 

录制_2024_05_14_14_27_20_223.gif

 

Etiquetas