web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Column 'XYZ' is invalid in the ORDER BY clause error 

(1) ShareShare
ReportReport
Posted on by 636
Hi Experts,
 
I am getting below error while moving one of my report code from AX 2012 to Visual studio to build the same for D365 F&O. can someone help me to rewrite the code and clarify the issue with it. It works fine with AX 2012. 
 
LedgerJournalTrans   _ledgerJournalTrans, _ledgerJournalTrans1;
 
select sum(AmountCurDebit), avg(ExchRate) from _ledgerJournalTrans1 order by OffsetLedgerDimension asc group by LedgerDimension
where _ledgerJournalTrans1.AccountType == LedgerJournalACType::Vend
&& _ledgerJournalTrans1.OffsetAccountType == LedgerJournalACType::Bank
&& _ledgerJournalTrans1.TransactionType == LedgerTransType::Payment
&& _ledgerJournalTrans1.LedgerDimension == _ledgerJournalTrans.LedgerDimension
&& _ledgerJournalTrans1.OffsetLedgerDimension == _dimAttrValueCombination.RecId;
 
Error:- Column 'OffsetLedgerDimension' is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause    
I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    238,129 Most Valuable Professional on at
    The error message is correct - ordering by OffsetLedgerDimension doesn't make a good sense if it never has any value (because it's neither grouped by nor aggregate it). If you're saying that you're satisfied with the behavior anyway, you can simply remove the order by clause.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 679 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 410 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 292 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans