Skip to main content

Notifications

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 592
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    
  • Verified answer
    Martin Dráb Profile Picture
    232,980 Most Valuable Professional on at
    Column 'XYZ' is invalid in the ORDER BY clause error
    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

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,219 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,980 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans