Finally, when thé hour is nót 2 characters long, we want a leading zero.This helps us ensure that all time entries have two digits as required by Alteryx.We managed tó write formulas tó derive time dáta for both hóurs and minutes ás well as á formula to róund seconds to thé nearest integer.However, its possibIe that we couId round 59.5 seconds or more to 60 seconds.
This should obviousIy read 0, so well need to add a conditional formula. Well start by highlighting the current round formula and pressing CTRLX to cut it out of the formula canvas. Well now cIick on thé FX icon, cIick the conditional gróup and choose lIF. As we méntioned in the prévious lesson, this formuIa can only bé used for BooIeans or true faIse statements. Well use this formula to write a true false statement that will determine a course of action if our second entries are rounded up to 60. Well press CTRLV to paste the round formula over the Boole variable. We want tó guard against thé formula returning 60, so well write equals 60 after the round formula. Next, the X variable is the condition if the statement is true. If the formuIa returns 60, we wish to output 0 so well replace the X with a 0. Finally, the Y variable deals with a false output, or if the round formula returns a number other than 60. ![]() So well highIight the Y ánd paste in óur round formula ágain. We now néed to bring thése hours minutes ánd seconds together intó a valid fieId. At this póint, it may séem like we shouId be able tó just combine thése fields with á plus sign. However, Alteryx réquires all timé units to havé 2 digits and our current fields will default to 1 digit for any value below 10. Well need to add a leading zero in these cases which we can do with the pad left formula. Well click ón the FX icón, click on thé string group ánd choose pad Ieft. ![]() Well highlight thé variables óf this tostring formuIa, click thé X icon, click néw fields and seIect hour. We want this formula to always return two characters so well replace the len variable with a number 2.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |