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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

sales detail in desc order

(0) ShareShare
ReportReport
Posted on by 371

want to arrange the amount in desc order how to do that...

static void AMY_job14(Args _args)
{
CustInvoiceJour CustInvoiceJour;
CustTable CustTable;
AccountNum AccountNum;
AmountMST TotalSalesBalance;
while select CustTable

{
AccountNum = CustTable.AccountNum;

while select sum(InvoiceAmount) from CustInvoiceJour where CustInvoiceJour.InvoiceAccount == CustTable.AccountNum


{

info(strFmt("%1....%2",AccountNum,CustInvoiceJour.InvoiceAmount));
}
}
}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,286 on at

    Hi Vinay Tak,

    You can use order by, something like

    while select sum(InvoiceAmount) 
    from CustInvoiceJour 
    order by InvoiceAmount desc 
    where CustInvoiceJour.InvoiceAccount == CustTable.AccountNum


    Please read this msdn article for details msdn.microsoft.com/.../aa656402.aspx

  • CU02060633-1 Profile Picture
    371 on at

    @ievgen Miroshnikov its not working it will not arrange in desc order when i apply this code

    static void AMY_job15(Args _args)

    {

       CustInvoiceJour         CustInvoiceJour;

       CustTable               CustTable;

       AccountNum              AccountNum;

       AmountMST               TotalSalesBalance;

      while select  CustTable

      {

           AccountNum = CustTable.AccountNum;

           while select sum(InvoiceAmount)

               from CustInvoiceJour

              order by CustInvoiceJour.InvoiceAmount desc

                 where CustInvoiceJour.InvoiceAccount == CustTable.AccountNum

                 {

               info(strFmt("%1....%2",AccountNum,CustInvoiceJour.InvoiceAmount));

           }

       }

    }

  • Mea_ Profile Picture
    60,286 on at

    What do you mean under "not working" ? It's not selecting data in desc order or you have compile error ?

  • Mea_ Profile Picture
    60,286 on at

    it should be

    order by InvoiceAmount desc

    not  

    order by CustInvoiceJour.InvoiceAmount desc

  • CU02060633-1 Profile Picture
    371 on at

    it's not selecting data in desc order or acs order  when i write the code " order by InvoiceAmount desc " also means there is no effect on the info log

  • Verified answer
    Mea_ Profile Picture
    60,286 on at

    Hey Vinay Tak,

    You are actually right. I totally forgot that you cannot do order by aggregated field in AX, it just ignores order by statement.

    To overcome this issue you can create simple view that has 2 fields: invoice account and sum of invoice amounts with grouping by invoice account.

    14782.Untitled1.png14782.Untitled1.png

    Now you can use next job:

        CustInvoiceJourSumAmountView  custInvoiceJour;
        
        
        while select SumOfInvoiceAmount, InvoiceAccount from custInvoiceJour 
            order by SumOfInvoiceAmount desc
        {
            info(strFmt("%1....%2", custInvoiceJour.InvoiceAccount, custInvoiceJour.SumOfInvoiceAmount));
        }


    It will give you accounts ordered by total invoice amount in desc order.

  • CU02060633-1 Profile Picture
    371 on at

    thank you @ievgen Miroshnikov for  help..after making view its works.....thanku so much more more thing i learn today....

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Sanhthosh.Kumar.K Profile Picture

Sanhthosh.Kumar.K 2

#2
Raed Salah Bzour Profile Picture

Raed Salah Bzour 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans