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

Community site session details

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

Getting only distinct values

(0) ShareShare
ReportReport
Posted on by 390

Hey community, I want to ask that how can I only get unique Production ID i.e. 1000, 1330 and 1600 and I don't want it to be repetitive like it is in the picture below. It should consist of only three lines each for one Production ID. Kindly suggest how can I do that.

pastedimage1673445852352v1.png

I have the same question (0)
  • Suggested answer
    Mohana Yadav Profile Picture
    60,977 Super User 2025 Season 2 on at
    RE: Getting only distinct values

    Is it a custom table/page?

    How are you filling this table now?

    can you show the code?

  • Muhammad Anas Naeemi Profile Picture
    390 on at
    RE: Getting only distinct values

    Actually I am getting the data from a query. and yes I'm inserting it in a custom table. the query contains repetitive values. this is how I'm getting values but they are repetitive as shown in the above image

    pastedimage1673448290353v1.png

  • Ayala Profile Picture
    112 on at
    RE: Getting only distinct values

    Hi,

    If you have the option to work with query object. You can create some like this:

    query 60100 DistinctValues
    {


        elements
        {
            dataitem(SalesLine; "Sales line")
            {
                column(LineNo; "Line No.")
                {

                }

                column(Count)
                {
                    Method = Count;
                }
            }
        }


    }
    It will return dataset with unique line no. You can find more information on Aggregate and sort data in a query - Training | Microsoft Learn
    I hope this will help you
  • Suggested answer
    Ayala Profile Picture
    112 on at
    RE: Getting only distinct values

    HI,

    On query to get unique values you must group only for those unique fields you need to obtain.

  • Suggested answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    14,243 Super User 2025 Season 2 on at
    RE: Getting only distinct values

    Check if your query has at least one aggregate column to trigger the distinct.

    Refer to below link for more information.

    thatnavguy.com/.../

  • Suggested answer
    YUN ZHU Profile Picture
    93,874 Super User 2025 Season 2 on at
    RE: Getting only distinct values

    Hi, You can also directly add a loop that inserts a new row if it doesn't exist and modifies the record if it exists, which is also more convenient.
    But defining in Query is the best performance.

    Hope this helps as well.

    Thanks.

    ZHU

  • Muhammad Anas Naeemi Profile Picture
    390 on at
    RE: Getting only distinct values

    Hey, still unclear. Can you show me the code for this?

  • Muhammad Anas Naeemi Profile Picture
    390 on at
    RE: Getting only distinct values

    Yes teddy I have used Method=Sum but it's not working. I tried to use count but my fields are integer and not code.

  • Suggested answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    14,243 Super User 2025 Season 2 on at
    RE: Getting only distinct values

    The query should retrieve the distinct records for all the fields specified in the query object, not the ones specified in your procedure logic.

    You didn't post your query, but I can see that you commented out some of the query fields on your screenshot.

    Things like uerMember or Description also being considered as part of distinct value.

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,214

#2
Sumit Singh Profile Picture

Sumit Singh 2,145

#3
YUN ZHU Profile Picture

YUN ZHU 1,887 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans