on 07-10-201801:56 PM - edited on 08-03-202111:24 AM by csalgado5
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!
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.
Typically, this will be something like
“Select a Date”
“What is the date?”
“Choose a Start Date”
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.
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.
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.
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.
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.
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.
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.
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.
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 theDate 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 firstname.lastname@example.org you’d like your creative tool uses to be featured in the Tool Mastery Series.
Stay tuned with our latest posts everyTool Tuesdayby followingAlteryxon Twitter! If you want to master all the Designer tools, considersubscribingfor email notifications.