Inspire EMEA 2022 On-Demand is live! Watch now, and be sure to save the date for Inspire 2023 in Las Vegas next May.

Alteryx Designer Discussions

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

Selecting a column where the column name is the current month.

rajivkarai
6 - Meteoroid

Hi,

I need to design a workflow, where i select a column based on the condition that the column name is the current month, 

I have attached a sample data set.

 

My final output should be:

Column1 | Column2 | May-19 | May-20 | Apr-19 | Apr-20

 

Kindly Help.

5 REPLIES 5
T_Willins
14 - Magnetar
14 - Magnetar

Hi @rajivkarai,

 

You can actually do this in a single tool:  Dynamic Select.  By selecting by formula, you can select the two columns you always want, then using DateTime formulas select the periods based on the current date.

 

Dynamic Select.png

 

 

 

grossal
15 - Aurora
15 - Aurora

Hi @rajivkarai,

 

you can do this using the Dynamic Select Tool in combination with DateTime Formulas:

 

grossal_0-1589870428594.png

The formula looks like this:

grossal_1-1589870446310.png

 

The first condition makes sure we have the first two columns and the other ones calculate the four months you want.

 

I have attached the sample workflow for you. Let me know if this solves your problem.

 

 

Best

Alex

rajivkarai
6 - Meteoroid

If the column name are 

2020-04-01| 2020-05-01 instead of Apr-20 | May-20 then how would the formula have to be modified??

 

Thanks for the reply.. the solution was inpressive.

grossal
15 - Aurora
15 - Aurora

Change to formula to:

 

[FieldNumber] IN (1,2) OR 
[Name] IN 
(DateTimeFormat(DAteTimeTrim(DateTimeToday(),'firstofmonth'),'%Y-%m-%d'),
DateTimeFormat(DAteTimeTrim(DateTimeAdd(DateTimeToday(),-1,'month'),'firstofmonth'),'%Y-%m-%d'),
DateTimeFormat(DAteTimeTrim(DateTimeAdd(DateTimeToday(),-12,'month'),'firstofmonth'),'%Y-%m-%d'),
DateTimeFormat(DAteTimeTrim(DateTimeAdd(DateTimeToday(),-13,'month'),'firstofmonth'),'%Y-%m-%d')
)

 

I check it here first, so it should generate the right results.

grossal_0-1589893587425.png

 

 

Let me know if this solved the problem! 

dawnh80
8 - Asteroid

I totally used this example for a student! 

Labels