cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx Knowledge Base

Definitive answers from Designer experts.
Announcement | Looking to expand your Alteryx skillset?! Check out the latest set of interactive lessons in Alteryx Academy: Creating Analytic Apps

Tool Mastery | Date

Quasar
Date.png

This article is part of the Tool Mastery Series, a compilation of Knowledge Base contributions to introduce diverse working examples for Designer Tools. Here we’ll delve into uses of the Date Tool on our way to mastering the Alteryx Designer:

 

You’re creating an app that involves dates. You want the user to be able to dynamically select the dates being used in the app, though. The tools you already know may not work. A Text Box would be too messy and allow lots of room for error. Pre-defined Drop Downs and List Boxes aren’t dynamic enough. Ah ha! What about that tool that looks like a calendar? The Date tool in the Interface category provides the perfect solution!

 

ThisYearWentByQuickly.gif

 

Note: This Tool Mastery assumes you have basic knowledge of apps and how to create them. If you need to brush up on this knowledge, review this Tool Mastery. You could also complete tutorial 6 in your designer or read this documentation page online.


The Date tool has minimal configuration. In fact, the tool/app could run successfully even if the configuration is never changed whatsoever from the time the tool is put on the canvas. In order for the app to make more sense to the user, though, I recommend changing the configuration settings. Simply type in the textbox the phrase that you wish to be displayed above the calendar to the user when they run the app.
 

 

1.png

 

Typically, this will be something like

  • “Select a Date”
  • “What is the date?”
  • “Choose a Start Date”

 

2.png

 

The user will then be able to select whichever date they like, and that will flow through the workflow. Then, you can Filter, use this date in a Formula tool, or anything else you would normally want to do with a date.

 

See the attached 2018.1 files, Date Tool Mastery 1.yxwz, Date Tool Mastery 2.yxzp, and Date Tool Mastery 3.yxzp, to follow along below and to see the Date tool in action.

 

1. Calculate how many days there are between today and the date selected

In the first example, a Generate Rows tool is used simply to create a record with today’s date. The Formula tool first creates a field with the value of the user’s date, getting the date input using a constant. Secondly, the Formula tool creates a field that calculates the difference, in days, between the user selected date and today.

 

3.png

 

Note: In the attached workflows, you will see that Action tools are not used. Instead, the output from the Date tools are being captured using a workflow constant in the “%Question.ToolName%” format. An Action tool could be used, but I like using this way because it looks cleaner and is easier for me. To learn more about using constants, see this article on the Community.

 

The user will see a calendar appear when they run the app. Today’s date will have a blue border. Once the use selects a date, it will be highlighted blue. Once they click ‘Finish’ the date will flow through to the downstream processes.  

 

4.png

 

Depending on how the app is set up, results may appear to the user. In this case, the Browse appears when clicking Finish. Other apps may write to a file or kick off the start of another app.

 

5.png

 

2. Sum the sales between two dates

Apps don’t have to be limited to just one Date tool. In the next example, two Date tools are used to capture sales, by category, for a company between two user selected dates.

 

6.png

 

In this app, the user is interested in the sales for each product category. One user may be interested in just the second quarter, however, while another user may want to see sales for the entire year of 2017. The Date tool allows for all of these possibilities.

 

7.png

 

As @NicoleJohnson and @MarqueeCrew explained in this discussion board, there is no way to set min and max values to limit the user’s choices on the front end. You can add an Error Message tool, though, so that the app displays an error if the selected date is not within a range set inside the app’s workflow.


In this specific example, an Error Message tool is used to verify that the end date is after the start date. Also here, if the user selects a date range that is not contained in the data, no records will appear in the output. 

 

8.png

 

9.png

 

3. Find out what has happened on a specific date in history

Need to include the input date as part of a dynamic string? The next example enables you to see what has happened on a certain date and any well-known births and deaths on that date by modifying a URL with the user's chosen date.

 

10.png

 

In this example, the Formula tool first uses the date from the Date tool and appends it to the URL, formatting as necessary. Concatenating is easy. Per usual, just include the strings that you want to bring together separated by a ‘+’ symbol.

 

 

[Address]+LowerCase(DateTimeFormat("%Question.Date%","%B/%d"))
 

 

This Formula tool also creates a field that includes the chosen date and will be used as the header/title of the report.

 

"On this day: " + DateTimeFormat("%Question.Date%","%B %d")

 

 

From here, the macro takes the generated URL and grabs all of the necessary information from https://www.timeanddate.com/on-this-day/ then formats it so it can be easily read. A table is created to view the output.

 

11.png

 

This can be extended to any URL you know that has a date in it (modifying the macro to match each URL’s incoming format, of course)! Here are just a couple illustrations:

 

In this discussion on the Community, a user was struggling using the Date tool for the first time and @patrick_digan was able to point them in the right direction by checking their use of quotes.

 

If you need to brush up on how to manipulate the date format that is coming from the Date tool, check out this documentation guide.

 

By now, you should have expert-level proficiency with the Date Tool! If you can think of a use case we left out, feel free to use the comments section below! Consider yourself a Tool Master already? Let us know at community@alteryx.com if you’d like your creative tool uses to be featured in the Tool Mastery Series.

 

Stay tuned with our latest posts every Tool Tuesday by following Alteryx on Twitter! If you want to master all the Designer tools, consider subscribing for email notifications.

Contributors