<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Default Sorting on Aggregate Results - Acumatica Generic Inquiries &amp; Pivot Tables				            </title>
            <link>https://www.augforums.com/forums/acumatica-generic-inquiries/default-sorting-on-aggregate-results/</link>
            <description>Acumatica User Group Forums</description>
            <language>en-US</language>
            <lastBuildDate>Tue, 21 Apr 2026 00:34:00 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: Default Sorting on Aggregate Results</title>
                        <link>https://www.augforums.com/forums/acumatica-generic-inquiries/default-sorting-on-aggregate-results/#post-8810</link>
                        <pubDate>Mon, 17 May 2021 23:49:53 +0000</pubDate>
                        <description><![CDATA[Good one Tim]]></description>
                        <content:encoded><![CDATA[<p>Good one Tim</p>]]></content:encoded>
						                            <category domain="https://www.augforums.com/forums/acumatica-generic-inquiries/">Acumatica Generic Inquiries &amp; Pivot Tables</category>                        <dc:creator>Jeffrey Patch</dc:creator>
                        <guid isPermaLink="true">https://www.augforums.com/forums/acumatica-generic-inquiries/default-sorting-on-aggregate-results/#post-8810</guid>
                    </item>
				                    <item>
                        <title>RE: Default Sorting on Aggregate Results</title>
                        <link>https://www.augforums.com/forums/acumatica-generic-inquiries/default-sorting-on-aggregate-results/#post-8808</link>
                        <pubDate>Mon, 17 May 2021 23:24:51 +0000</pubDate>
                        <description><![CDATA[Thank you for posting, that is a nice feature]]></description>
                        <content:encoded><![CDATA[<p>Thank you for posting, that is a nice feature</p>]]></content:encoded>
						                            <category domain="https://www.augforums.com/forums/acumatica-generic-inquiries/">Acumatica Generic Inquiries &amp; Pivot Tables</category>                        <dc:creator>davidhunter</dc:creator>
                        <guid isPermaLink="true">https://www.augforums.com/forums/acumatica-generic-inquiries/default-sorting-on-aggregate-results/#post-8808</guid>
                    </item>
				                    <item>
                        <title>Default Sorting on Aggregate Results</title>
                        <link>https://www.augforums.com/forums/acumatica-generic-inquiries/default-sorting-on-aggregate-results/#post-8807</link>
                        <pubDate>Mon, 17 May 2021 19:02:29 +0000</pubDate>
                        <description><![CDATA[If you create a Generic Inquiry in Acumatica and group, you can get summarized values like totals. But what if you want to sort based on the aggregate values?
I had this scenario today wher...]]></description>
                        <content:encoded><![CDATA[<p>If you create a Generic Inquiry in Acumatica and group, you can get summarized values like totals. But what if you want to sort based on the aggregate values?</p>
<p>I had this scenario today where I wanted to look at all Invoice Lines for the last year, group by Item, view the total quantity sold, and have the rows sorted by the highest total quantity sold on the top.</p>
<p>In this case, the Generic Inquiry was smarter than I expected it to be.</p>
<p>I tried the following in Acumatica 2020 R1 (20.114.0020).</p>
<p> </p>
<p>I had these columns on the <span style="text-decoration: underline">RESULTS GRID</span> tab of the <span style="text-decoration: underline">Generic Inquiry (SM208000)</span> screen:</p>
2355
<p> </p>
<p>I was grouping by one field on the <span style="text-decoration: underline">GROUPING</span> tab of the <span style="text-decoration: underline">Generic Inquiry (SM208000)</span> screen:</p>
2353
<p> </p>
<p>The results looked like this:</p>
2354
<p> </p>
<p>As you can see in the previous screenshot, the data isn't sorted on the <span style="text-decoration: underline">Qty Purch last 12 Months</span> column. I could click on the <span style="text-decoration: underline">Qty Purch Last 12 Months</span> column and sort in <span style="text-decoration: underline">Descending</span> order to get what I wanted, but that would be an on-the-fly sort which is only for my user and which isn't remembered the next time I open the screen.</p>
<p>I wanted it to be sorted on the <span style="text-decoration: underline">Qty Purch Last 12 Months</span> column in <span style="text-decoration: underline">Descending</span> order by default for all users every time they open the screen.</p>
<p> </p>
<p>On the <span style="text-decoration: underline">SORT ORDER</span> tab, I tried sorting by the =Sum() aggregate value which made sense to me:</p>
2356
<p> </p>
<p>But I got this error message when trying to run the Generic Inquiry:</p>
<pre contenteditable="false">Cannot perform an aggregate function on an expression containing an aggregate or a subquery.</pre>
2357
<p> </p>
<p>Then I tried sorting on the field name only, not really expecting it to work:</p>
2358
<p> </p>
<p>But it worked!</p>
2359
<p> </p>
<p>The Generic Inquiry was smarter than I expected it to be because it sorted on the aggregate values even though I didn't tell it to.</p>
<p> </p>
<p>Checking the Trace on the Generic Inquiry and looking at the SQL code, you can see that Acumatica automatically wrapped the field in the SUM formula. Somehow it was smart enough to do that:</p>
2360
<p> </p>
<p> </p>
<p>Good job Acumatica!</p>]]></content:encoded>
						                            <category domain="https://www.augforums.com/forums/acumatica-generic-inquiries/">Acumatica Generic Inquiries &amp; Pivot Tables</category>                        <dc:creator>Tim Rodman</dc:creator>
                        <guid isPermaLink="true">https://www.augforums.com/forums/acumatica-generic-inquiries/default-sorting-on-aggregate-results/#post-8807</guid>
                    </item>
							        </channel>
        </rss>
		