Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

Assistance on filtering factbox results

(0) ShareShare
ReportReport
Posted on by 5

Hello everyone, I'm new to AL and still learning about how the language functions. Recently, I've been trying to create a fact box that get me Item Totals by each location. 

The format is so:  Location Code - Item No. - Quantity Available  

Screenshot-_2800_6_2900_.png

I'm able to get the data that I need but the issue is that I get multiple entries for one location and Item No, When I only need one entry per location. Can anyone assist me on this ? I tried playing around with the source tables and changed it to Location which helped reduce the number of results I get but then Quantity available remains at zero. 

Source Code: 

page 50146 "Availability by Location"
{
    Caption = 'Availability by Location';
    PageType = CardPart;
    SourceTableTemporary = True;
    SourceTable = "Item Ledger Entry";
    //SourceTable = Location;
    layout
    {
        area(Content)
        {
            repeater(group)
            {

                field("Code"; Rec."Location Code")
                {
                    ApplicationArea = All;
                }
                field("Item No."; Rec."Item No.")
                {
                    ApplicationArea = All;
                }
                field("Qty Available"; Rec."Quantity by Location")
                {
                    Caption = 'Quantity Available';
                    ApplicationArea = All;
                    //"Item Ledger Entry".setCurrentKey()
                    DrillDown = true;
                    trigger OnDrillDown()
                    var
                        ILE: Record "Item Ledger Entry";
                        LocationMatrixPage: Page "Items by Location Matrix";
                        Item: Record Item;
                        ItemVariant: Record "Item Variant";
                        Text000: Label 'The record was found';
                    begin
                        ItemVariant.SetFilter("Item No.", Rec."Item No.");
                        PAGE.Run(50036, ItemVariant);
                    end;
                }

            }

        }
    }

    var 

        Item: Record "Item Ledger Entry";
        Location: Record Location;
}

  • Suggested answer
    xavierespi Profile Picture
    xavierespi 5 on at
    RE: Assistance on filtering factbox results

    Thank you Yen Zhu, I was able to get it working !

  • xavierespi Profile Picture
    xavierespi 5 on at
    RE: Assistance on filtering factbox results

    Ill give this a try and update you on the results

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,081 Super User 2024 Season 1 on at
    RE: Assistance on filtering factbox results

    Hi xavierespi ,

    You can use item by Location as Zhu mentioned.

    Thanks.

  • Verified answer
    YUN ZHU Profile Picture
    YUN ZHU 75,802 Super User 2024 Season 2 on at
    RE: Assistance on filtering factbox results

    Hi, Query object is best performance when doing this kind of customization in Business Central.

    The following is an example of a standard feature.

    pastedimage1654822961678v1.png

    pastedimage1654823351350v3.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;
    }

    And then you can use Query.Open Method to add query data to a page.

    https://yzhums.com/4869/

    Hope this helps as well.

    Thanks.

    ZHU

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 993 Super User 2024 Season 1 on at
    RE: Assistance on filtering factbox results

    You should be able to use the Item table if you set the location filter for every location.

    That is more efficient for your performance that doing all the calculation of the item ledger table.

    So for the item you want to look at you loop trough your locations.

    In the location filter on your item you put the location code and then do a calcfields on the inventory column.

  • xavierespi Profile Picture
    xavierespi 5 on at
    RE: Assistance on filtering factbox results

    Is there a way I could accomplish my goal while using just the Item Ledger entry table ?

  • Suggested answer
    JAngle Profile Picture
    JAngle 46 on at
    RE: Assistance on filtering factbox results

    Try stocking keeping unit table. Will mean you need to create the data. It has a flowfield for inventory, qty. on sales, qty. on purchase.

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,703 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,433 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans