I have a file that has column headings which contain the names of the most recent 3 months. So obviously next month's columns would show different months than this month's. I have 3 sets of these for 3 different metrics where I want to see their values across 3 months. The problem is when a new month comes, it puts the new months at the end.
So instead of the desired order like CPU_2023-05,CPU_2023-06,CPU_2023-07, RPU_2023-05,RPU_2023-06,RPU_2023-07 I get CPU_2023-05,CPU_2023-06, RPU_2023-05,RPU_2023-06,CPU_2023-07,RPU_2023-07
Just moving unknown columns in the select tool doesn't work because the unknown columns would still be at the end vs. in order with their respective metric. So I tried to create an input with the next few years' worth of these column names, add it to a union, have them in the order I want, remove the Union, and then they would still be in order but as missing columns. So when they appear they would be in the right order. I am finding though that somewhere at the table tool to report tool top format and output, it loses these missing columns and the order.
Is there a way to get the columns in the right order for future months? Thanks!
Apologies as I am not at my computer, but I would Transpose the data and CrossTab it back, possibly with a Sort tool in between! In the Transpose you'd make your Key columns everything except the columns above and the Data columns would be these columns, then in the Crosstab you'd Group By the same key columns, change column headers to "Name" and values for new columns would be "Value". Then select an aggregation method - Sum for numeric and Concat for string is most common.
I dont know if i understood your problem properly, but if you want to order columns from before to after dynamically, the attached workflow will do this for you.
Before: CPU_2023-05,CPU_2023-06, RPU_2023-05, RPU_2023-06,CPU_2023-07,RPU_2023-07
After: CPU_2023-05,CPU_2023-06, CPU_2023-07, RPU_2023-05,RPU_2023-06,RPU_2023-07