Alteryx Designer Desktop Discussions

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

How to select column names with the Prior and latest date

lumjingbki
8 - Asteroid

Hi I have a the below data set which has 7 days sales details I want to select only the latest  20231013_1 and the previous latest date 20231010_1 column. Can someone please suggest how to go about 

 

 

 

ProductsShope Code20231003_120231006_120231007_120231008_120231009_120231010_120231013_1Total salesLast SalesTargetNotes
AppleApp        1,198.00   113,810.00          125.00         250.00        1,198.00      89,850.00            225.00   206,656.00023000Highest sales
ApplePpa              1,198.00       1,198.00019000Low sales 
AppleRal                  500.00           500.00060000 
Mangosqw            225.00       6,075.00          225.00   14,400.00            500.00      30,000.00        1,198.00     52,623.00023000 
Orangeree        1,198.00     67,088.00          225.00     3,375.00        1,198.00    107,820.00        1,198.00   182,102.00023000 
Orangerew            500.00     30,000.00            58.50     5,616.00            500.00      14,500.00        1,198.00     52,372.50023000 
Orangewqe        1,198.00     89,850.00          500.00   25,000.00              58.50            936.00            500.00   118,042.50019000 
Pineapplewsx        1,198.00   107,820.00      1,198.00   43,128.00            500.00      14,000.00        1,198.00   169,042.00060000 
Bananasde        1,198.00     38,336.00          225.00         225.00            225.00        3,375.00        1,198.00     44,782.00023000 
Bananacde            500.00     30,000.00          225.00         225.00              58.50        5,616.00            500.00     37,124.50023000medium sales
Bananavfr        1,198.00   107,820.00            58.50           58.50            225.00        3,375.00        1,198.00   113,933.00023000 
Bananabgt            500.00     14,500.00          500.00         500.00              58.50        5,616.00            500.00     22,174.50019000 
Banananhy            500.00     40,500.00      1,198.00     1,198.00            225.00        3,375.00        1,198.00     48,194.00060000 
Mangomju        1,198.00     41,930.00          500.00         500.00              58.50        5,616.00            500.00     50,302.50023000 
3 REPLIES 3
niklas_greilinger
9 - Comet

Hello,

here is one way of doing this. Take the metadata from the columns and sort by the column name. Then Change the description of the latest columns and only keep these columns. WF shows how to do it.
Example_WF.png

caltang
17 - Castor
17 - Castor

Like so:

 

image.png

 

This method is dynamic to your data. Whatever data you throw inside, it will always get you the Max and Max-1, and it returns it to its original shape of the data. 

 

If you just want the max and max-1 columns, just add a Select tool near the end to get what you want by dropping the rest and choosing "Dynamic".

 

Hope this helps @lumjingbki 

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
AndrewDMerrill
13 - Pulsar

Another more simplified version that is still dynamic, although this workflow does assume that dates columns' names will be formatted to have 8 characters: yyyyMMdd_1, and that no other columns will have 8 consecutive digits in their column name.

Screenshot.png

Labels