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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Item Ledger Calculation

(0) ShareShare
ReportReport
Posted on by 31

Hi there,

I'm trying to do the calculation of remaining quantity for each item per Location Code from the Item Ledger Entry table in SQL, but I'm running into a few obstacles.

Would this just be regarding negative and positive output (Entry Type)? I've thought about taking latest date but that's not a solid enough rule.

Any help would be greatly appreciated.

Thanks

Liam

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,708 Moderator on at

    Hi,

    There are other entry type like Purchase,Sale,Positive Adjmt.,Negative Adjmt.,Transfer,Consumption,Output, ,Assembly Consumption,Assembly Output

    Thanks.

  • Liamh501 Profile Picture
    31 on at

    Hi Nitin,

    Thanks for responding.

    What I want is to get the latest remaining quantity for each item by location code, I just didn't know how to get there?

    Thanks

    Liam

  • Suggested answer
    Nitin Verma Profile Picture
    21,708 Moderator on at

    Hi,

    You can have an idea with the below link

    stackoverflow.com/.../sql-query-get-top-sold-items-from-table-with-cols-saled-qty-item-no-no

  • Suggested answer
    Dallefeld Profile Picture
    211 User Group Leader on at

    Item Availability by Location has the Inventory as one of the fields.

    Just take all item ledger entries with remaining quantity <>0 to Excel, run a quick pivot by location.

  • Suggested answer
    YUN ZHU Profile Picture
    95,697 Super User 2025 Season 2 on at

    Hi, If it is viewed in the NAV, I recommend referring to a standard Query of BC.

    pastedimage1657582088555v1.png

    pastedimage1657582168456v2.png

    query 2554 "Items By Location"
    {
        QueryType = Normal;
        OrderBy = ascending (No);
        Caption = 'Items By Location';
        QueryCategory = 'Item List';
    
        elements
        {
    
            dataitem(Item; Item)
            {
                column(No; "No.")
                {
                    Caption = 'No.';
                }
    
                column(Description; Description)
                { }
    
                dataitem(Item_Ledger_Entry; "Item Ledger Entry")
                {
                    DataItemLink = "Item No." = Item."No.";
    
                    column(Location_Code; "Location Code")
                    {
                        Caption = 'Location Code';
                    }
    
                    column(Remaining_Quantity; "Remaining Quantity")
                    {
                        Caption = 'Remaining Quantity';
                        Method = Sum;
                    }
                }
            }
        }
    
        trigger OnBeforeOpen()
        begin
    
        end;
    }

    Hope this helps as well.

    Thanks.

    ZHU

  • Liamh501 Profile Picture
    31 on at

    Thanks for this Kim. I'm doing a SQL query but still works this way.

    Thanks again

    Liam

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

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,606

#2
YUN ZHU Profile Picture

YUN ZHU 931 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 773 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans