How to sort by SUM result (1 Viewer)

ariansman

Registered User.
Local time
Today, 06:56
Joined
Apr 3, 2012
Messages
157
I have made a report such as the following



Studentname yearlycost

John 21000

Steve 27000

Jack 22000

Amanda 20000



The yearlycost is the sum of monthly_cost of each student and is created by the SUM function of the report. How can I sort the report based on the yearlycost? Since yearlycost was not in the report in the first place and was later created by the SUM function of the report, I don’t see an option to sort the report based on the yearlycost.

Thank you
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:56
Joined
May 7, 2009
Messages
19,233
create a Total query from your table/query and use the New Query
for your report. you can Add Sorting on the Report desgin.
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:56
Joined
Sep 21, 2011
Messages
14,235
Get the sum in the query and use that in the report sort.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:56
Joined
Oct 29, 2018
Messages
21,455
Reports have their own sorting section. You can actually sort the report any way you like, even by using an expression like Sum.
 

ariansman

Registered User.
Local time
Today, 06:56
Joined
Apr 3, 2012
Messages
157
Reports have their own sorting section. You can actually sort the report any way you like, even by using an expression like Sum.
Sum does not show up in the droplist for sorting. Do I have to get the sum in the query and then sort it in the report?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:56
Joined
Oct 29, 2018
Messages
21,455
Sum does not show up in the droplist for sorting. Do I have to get the sum in the query and then sort it in the report?
No. Query sorts are ignored in reports. You should be able to select Expression from the dropdown and then use Sum() to sort.
 

ariansman

Registered User.
Local time
Today, 06:56
Joined
Apr 3, 2012
Messages
157
No. Query sorts are ignored in reports. You should be able to select Expression from the dropdown and then use Sum() to sort.
I opened the query in Datasheet view. In the Records group, I clicked Totals. In the Total row, I clicked the cell in the field that I want to sum, and then selected Sum from the list. Is this how we should get the Sum expression in the query? But I still do not see the sum in the report design view to sort it.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:56
Joined
Feb 19, 2002
Messages
43,223
No. The totals do not persist.

You need to create an actual totals query that sums the data. Then you can sort by the sum column in the report design. You don't put the order by clause into the query. It has to go into the table design properties.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:56
Joined
Oct 29, 2018
Messages
21,455
I opened the query in Datasheet view. In the Records group, I clicked Totals. In the Total row, I clicked the cell in the field that I want to sum, and then selected Sum from the list. Is this how we should get the Sum expression in the query? But I still do not see the sum in the report design view to sort it.
Hi. Sorry for the delay. I wasn't talking about your query. I am referring to your Report. It has a separate area for sorting.
 

Users who are viewing this thread

Top Bottom