Alteryx Designer Desktop Discussions

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

Can't add custom formula

Joshman108
8 - Asteroid

I've successfully added a simple, test formula to C:\Program Files\Alteryx\bin\RuntimeData\FormulaAddIn as described in this link.

 

But I am unable to add this particular formula:

 

<?xml version="1.0" encoding="utf-8"?>
<FormulaAddIn>
  <Function>
    <Name>cst_now</Name>
    <NumParams variable="false">0</NumParams>
    <Category>custom</Category>
    <InsertText>cst_now()</InsertText>
    <Description>If running on server, gets -5 or -6 from now() depending on whether we are in dst or not. If not running on server, it gets now(), which might not actually be cst if the user is not in central.</Description>
    <Formula> 
(if getEnvironmentVariable("USERNAME") = 'svc-alteryx-admin' THEN 
if 
(DateTimeNow() > datetimeparse("03/13/"+ToString(DateTimeYear(datetimenow()))+" 08","%m/%d/%y %H") 
and datetimenow() <  datetimeparse("09/06/"+ToString(DateTimeYear(datetimenow()))+" 07","%m/%d/%y %H")) 
then datetimeadd(datetimenow(),-5,'hour') 
else datetimeadd(datetimenow(),-6,'hour') endif 
else 
datetimenow() 
endif)
</Formula>
  </Function>
</FormulaAddIn>

 

and get this error when trying to open designer:

 

Joshman108_0-1669055209063.png

 

I assume something in the formula is being parsed wrong. Or maybe we're not allowed to use alteryx built-in formulas.

 

Any thoughts?

I know my cst conversion formula is wrong, ignore that.

 

1 REPLY 1
Joshman108
8 - Asteroid

It has something to do with the < symbol, so I just flipped the args around like this:

 

<?xml version="1.0" encoding="utf-8"?>
<FormulaAddIn>
  <Function>
    <Name>cst_now</Name>
    <NumParams variable="false">0</NumParams>
    <Category>custom</Category>
    <InsertText>cst_now()</InsertText>
    <Description>If running on server, gets -5 or -6 from now() depending on whether we are in dst or not. If not running on server, it gets now(), which might not actually be cst if the user is not in central.</Description>
    <Formula> 
(if getEnvironmentVariable("USERNAME") = 'svc-alteryx-admin' THEN 
if 
(DateTimeNow() > datetimeparse("03/13/"+ToString(DateTimeYear(datetimenow()))+" 08","%m/%d/%y %H") 
and (datetimeparse("09/06/"+ToString(DateTimeYear(datetimenow()))+" 07","%m/%d/%y %H") > DateTimeNow())) 
then datetimeadd(datetimenow(),-5,'hour') 
else datetimeadd(datetimenow(),-6,'hour') endif 
else 
datetimenow() 
endif)
</Formula>
  </Function>
</FormulaAddIn>
Labels