Hi. Is there a way to sort columns by date if the range of dates change each time the flow is run? For example, if it runs every day for the last 30 days, how do I maintain an ascending sort?
Thanks,
Jonathon
Hi. Is there a way to sort columns by date if the range of dates change each time the flow is run? For example, if it runs every day for the last 30 days, how do I maintain an ascending sort?
Thanks,
Jonathon
Hi @Jonathon_Jonas,
Quick question: You’re trying to sort columns by date, not rows, correct?
Hi Brian,
Yes, columns by date. Oldest date first and then most recent all the way to the right. And then include a total column as well as the final column on the right.
Thanks,
Jonathon
Got it. I think your best option would be to use the “flip table” step to get the columns turned into rows, then sort the rows, then use another flip step to get it back to having dates as the columns.
It’d look like this:
The tricky thing is getting a “total column”, because the “Math” step needs you to reference the names of columns, but the names of your columns will be changing, like you said.
The first step would be to get your source table looking like this (pic below) where there is a column called “Date” who’s value is “Amount”. Those two cells will become your headers once you flip the table.
(If you can change your source table, I’d just add those as the first column. Otherwise, you can add a column in Parabola and then re-order it so that it becomes the first column.)
2.Then, flip the table, then sort it:
Another question - is it always the same number of dates, or is that changing as well?
To follow up, you can get a total column by using the “Sum by group” step. First you would just add a placeholder column that you’ll use for the grouping.
In the end it’ll look like this:
The upper section is for getting a row where you have the total. Then you add that back to the rest of the data and flip the table back so that it’s in columns again.
The “Insert text column” step:
The “Sum by group” step:
Then you stack the tables and flip it back, so in the end you have something like this:
You can copy the snippet below and paste it into your flow to see all the steps I created above. Then you’d need to just connect your data source in place of the Google Sheets step you see in the screenshot above.
parabola:cb:b40cf0ce-9aec-46e5-94de-3cf44af7e905
Let me know if you have any questions about how any of this works and good luck!