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 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:

- Then, flip it back:

- Here, you could add a total column by using the Math step, but like I said, that wonâ€™t work long-term if the names of your columns are going to change.

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!

3 Likes