Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Server Discussions

Find answers, ask questions, and share expertise about Alteryx Server.

Dynamically Filter Data By Year column and populating the Sheet name based on the year.

Alteryxexpert
8 - Asteroid

I have data like below,

BusinessyearProfit
Cards202519.90%
Cards202618.10%
Cards202717.30%
Cards202816.50%
Cards202916.50%
Loans202553.30%
Loans202653.10%
Loans202751.80%
Loans202851%
Loans202951%

 

Now I want to Filter this data based on the year, not using conditions like year='2025', It should be dynamic, the data will have five years 2025 - 2030 and data needs to be filtered for all years and written to different sheets of an excel, like if 2025 data then the sheet name should be like FY25, if 2026 then sheet name should be like FY26 etc. Is this possible? and is it possible to dynamically populate sheet names while using a visual layout solution?

1 REPLY 1
cjaneczko
13 - Pulsar

To Dynamically filter the years you can use the following formula.

 

 

[year] > tonumber(DateTimeTrim(DateTimeNow(),'%Y')) and [year]<= tonumber(DateTimeAdd(DateTimeNow(),6,'years'))

 

 

To create the tabs you can create a new field in your data set to generate the sheet name for the filepath.

(Formula field name: [TabName])

 

'FY'+Right(ToString([year]), 2)

 

 

To create the sheet names you can use the following formula. 

 

 

[Engine.WorkflowDirectory]+' <Insert FileName Here> '+".xlsx|||"+[TabName]

 

 

And in the Output tool check the box to "Take File/Table name from field".