Alteryx Designer Desktop Discussions

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

Execute Different SQL Based on Day of Week

sdpeacock
7 - Meteor

Alteryx pros, I need some help and I hope that you can point me in the right direction.

 

Problem: I have have two separate SQL statements that connect to the same data sources but contain different columns, etc and return different results. If it's Monday then i need SQL#1 to run; however, if its Tue-Fri then I need SQL#2 to run.

 

I know that I could break this up into 2 workflows and set each on a schedule related to its respective day in Gallery but I wanted to see if this could be done in a single flow so I didn't have to worry about managing separate flows.

 

I appreciate any suggestions.

 

Thank you! 

5 REPLIES 5
atcodedog05
22 - Nova
22 - Nova

Hi @sdpeacock ,

 

Here is a pointer what you can do.

atcodedog05_0-1601578277108.png

You can use DateTimeNow to get current datetime later get the weekday number.

Later redirect to different flows using Filter tool.

 

Hope this helps : )


If this post helps you please mark it as solution. And give a like if you dont mind : )

 

Harbinger
9 - Comet

I would leverage the dynamic input and update the columns to pull from SQL based on the day of the week.

 

Here is what it would look like with a dynamic input tool! you'll need to configure the input data source template to the following format: SELECT COLUMNSTOREPLACE FROM theTableYoureQuerying WHERE yourconditions. 

sdpeacock
7 - Meteor

Thank you very much! I ended up using this logic in my workflow. Works like a charm! 👍

Harbinger
9 - Comet

@sdpeacock happy to help; that's a fun one!

MNewt9
7 - Meteor

Hello,

 

I have a very similar ask, I think.  I do want to use the server option and will be scheduling it to run each Monday morning for the prior week (Sunday to Saturday).  However, I want to be able to manually kick off the same WF on the server in the event we get asked to refresh the prior week on say a Wednesday, Friday, etc and still pull the full prior week of data.

 

I.e. Today is Wednesday so pull the a.PKUP_DT >= TODAY-10 and a.PKUP_DT< TODAY - 3 ELSEIF Today is Friday so pull the a.PKUP_DT >= TODAY-12 and a.PKUP_DT< TODAY - 5 and so on.

Labels