# Accounts and Subaccounts with History - Reverse Sorting

**URL:** <https://community.velixo.com/t/accounts-and-subaccounts-with-history-reverse-sorting/34>\
**Category:** Ideas & Feature Requests\
**Tags:** Acumatica\
**Created:** [November 20, 2023, 5:05pm UTC](https://community.velixo.com/t/accounts-and-subaccounts-with-history-reverse-sorting/34 "2023-11-20T17:05:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kirill\_Boyko](https://community.velixo.com/letter_avatar_proxy/v4/letter/k/59ef9b/32.png) [@Kirill\_Boyko](https://community.velixo.com/u/Kirill_Boyko)\
**Post date:** [November 20, 2023, 5:05pm UTC](https://community.velixo.com/t/accounts-and-subaccounts-with-history-reverse-sorting/34/1 "2023-11-20T17:05:55Z")

</div>

Hello,

We have a formula, ACCOUNTSANDSUBACCOUNTSWITHHISTORY, the order of data is always “take a GL account, then find all Subaccounts for that GL account that has activity. When done, move to the next GL account”. I would like to suggest the reverse sorting (“Take a Subaccount, find all affected GL accounts and list them in accending order, then, when done, move to the next Subaccount”)

Hope it makes sense.

---

<div class="post-metadata">

**Author:** ![Gabriel](https://community.velixo.com/user_avatar/community.velixo.com/gabriel/32/7_2.png) [@Gabriel](https://community.velixo.com/u/Gabriel)\
**Post date:** [November 20, 2023, 7:10pm UTC](https://community.velixo.com/t/accounts-and-subaccounts-with-history-reverse-sorting/34/2 "2023-11-20T19:10:14Z")

</div>

Kirill,

This can be achieved by using the =SORT() function, and optionally the CHOOSECOLS function if you want to have the subaccount code displayed first:

=CHOOSECOLS(SORT(ACCOUNTSANDSUBACCOUNTSWITHHISTORY(“Demo”, “ACTUAL”,“01-2019”, “12-2019”), {2,1}),2,1)

Attached is a screenshot showing the result.

 ![Screenshot 2023-11-20 at 2.09.59 PM.png](https://community.velixo.com/uploads/default/original/1X/7569367eb2e8eda55413d33d5d0717b715cc64b8.png)
