Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Date Interface - Update value with formula - multiple choice

PizzaMacro
5 - Atom

Hi.

 

I'm building an interface for an app which allows a field called "Payment release date" to be filtered, and said filter to be changed by a Date picker.

 

The Date interface allows me to pick between the Default [#2] value already on the filter ( [Destination]) or a custom Date provided by a Date picker interface ([#1]).

 

In all instances it seems like my input is ignored and the original date on the filter is the one being taken into consideration, rather than the one provided by the Date picker.

 

I know it has to do with the format of the value the Date picker returns, but after many unsuccessful tests I don't quite understand the type of value I'm manipulating.

 

One of many formulas I have tried:

IF [#2] THEN [Destination] ELSE "[Payment release date] = ToDate(" + [#1] + ")" ENDIF

 

if (boolean radio button) then (keep the value string untouched) else (change the value string to the date picker date)

 

I can't attach the workflow. But below is a screenshot.

 

Thank you for the help in advance!

 

date.PNG

5 REPLIES 5
Garrett
11 - Bolide

Have you considered adding a "Condition" into the mix. A "Condition" tool would allow the "Action" to be executed only if the condition is met (i.e. when user checks "Custom" and chooses a date). And then the "Default" selection doesn't need to execute any action.

 

Condition.PNG

PizzaMacro
5 - Atom

Hi. Unfortunately I'm getting the same results. Both the radio buttons and the method you proposed work just fine at the time of conditioning my choice.

 

The problem lies in how to handle the [#1] within the action tool.

 

At the time I need to update the Expression Value I need to know how to feed it into the result.

 

I have tried [#1], toString[#1], toDate[#1], datetimeformat, and combinations between these, as well as the variable as string equals any of the above ("[variable] = " [#1]) ... etc

Garrett
11 - Bolide

Ah got it.

 

For Actions that update expressions I find it easier to "Update Value" and "Replace a specific string", rather than try to re-write the entire expression (I think because of the need for all sorts of nested quotation marks):

 

UpdateValue-ReplaceSpecificString.PNG

 

MichalM
Alteryx
Alteryx

@PizzaMacro 

 

Do you want to try with the below configuration? If the Default is selected, I calculate yesterday's date, if the Custom, the date selector is used. Example workflow attached.

 

 

IF [#1] THEN DateTimeFormat(DateTimeAdd(DateTimeNow(), -1, "days"), "%Y-%m-%d")
ELSE [#3]
ENDIF

 

 

 select-date.png

PizzaMacro
5 - Atom

[Insert huge post reply here timed out by login error]

 

Hi.

Your example helped me figured it out. Had to do with the wonky way Alteryx handles expression values passed onto toos/controls.

 

The filter must be set to Custom or it won't work.

 

Why? I don't know. But these are the two methods that worked out for me:

 

---

Method 1:

Set up a fake date and replace it within the expression value in the action formula.

 

 

IF [#2] THEN replace([Destination],"2000-01-01",tostring(todate(datetimeadd(datetimetoday(),-1,"days")))) ELSE replace([Destination],"2000-01-01",tostring([#1])) ENDIF

 

 

In this case [Destination] is not a field. It's a variable created by Alteryx to refer to the expression value contents of the filter.

---

Method 2:

Replace the whole expression value within the action tool formula

 

 

IF [#2] THEN "[FieldToCompare] = " + '"' + DateTimeFormat(DateTimeAdd(DateTimeNow(), -1, "days"), "%Y-%m-%d") + '"' ELSE "[FieldToCompare] = " + '"' + tostring([#1]) + '"' ENDIF

 

 

in this case [FieldToCompare] is not a variable. It's a string which will later be interpreted by the filter as a field.

---

 

Thanks for the help.

I'm attaching a picture and both solutions in case anyone could ever benefit form them.

 

date.PNG

Labels