How to retrieve the filename of my input data in an expression? My task is to create an expression in Alteryx using formula tool where if the filename consists the word Q1, it will create a posting date "31/3" and the year will be the year of the file, and 30/6 for Q2 and so on until Q4. My expression is
IF Contains([FileName], "Q1") THEN
Date(DateTimeParse([FileName], "%Y"), 3, 31)
ELSEIF Contains([FileName], "Q2") THEN
Date(DateTimeParse([FileName], "%Y"), 6, 30)
ELSEIF Contains([FileName], "Q3") THEN
Date(DateTimeParse([FileName], "%Y"), 9, 30)
ELSEIF Contains([FileName], "Q4") THEN
Date(DateTimeParse([FileName], "%Y"), 12, 31)
ELSE
Null()
ENDIF
which apparently is not working as FileName is an unknown variable
Solved! Go to Solution.
Hi @imivan
If you are using Excel file as your input, then you can make use of this option to get the filename in your input also.
In the Input tool, under the options
5. Output File Name as Field -> select File Name Only
Many thanks
Shanker V