Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Dynamic in-DB filter

Stormphoenix
6 - Meteoroid

Please help!!

 

I'm new to both Alteryx and SQL and I'm struggling to write an expression in the in-DB filter tool that brings back only the last 12 months from whatever date the flow is run. 

 

I know I can bring it out of the database and use a normal filter tool and do it that way, but i'd rather keep the run time down as much as I can.

 

Any help would be much appreciated, thanks!

5 REPLIES 5
AngelosPachis
16 - Nebula

Hi @Stormphoenix ,

 

Can you try the following expression in you In-DB filter tool :

 

"YourDateFieldHere" >=Dateadd(month,-12,GetDate()) 

 

The getdate function will return today's date and then with the Dateadd function you will only keep records that are within the last 12 months.

 

Hope that helps,

 

Angelos

mbarone
16 - Nebula
16 - Nebula

You can do that with a Dynamic Input tool.  Read through the Tool Mastery Index|Dynamic Input Tool  section.  Basically, you'll create your "filter" on the Alteryx canvass.  And then feed that filter into your SQL that you created for your database.  Write the SQL for a particular time frame, and then you just swap out that time frame with the one you create on the canvas.

ChrisTX
15 - Aurora

This post from yesterday should help:

How to: Dynamic In-DB filtering without database writing permissions

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/How-to-Dynamic-In-DB-filtering-without...


Here's a list of all functions:  https://help.alteryx.com/current/designer/functions
Take a look at the date functions.

 

 

Stormphoenix
6 - Meteoroid

@AngelosPachis Brilliant, this worked perfectly, thanks so much!

Stormphoenix
6 - Meteoroid

@ChrisTX @mbarone  Thank you for the links, I'll definitely have a look through.

Labels