Why isn't there a COUNTUNIQUE in Navision?

Dear NAV experts,

I implemented a few functions in the past which required the use of something like a COUNT unqiue. Currently Navision doesn’t seem to have this in the language, which one could easily achieve using plain T-SQL:

SELECT DISTINCT [Item No_]

FROM SomeTable

WHERE set some filtering criteria…

So I ended up having to

SomeTable.RESET;

SomeTable.SETCURRENTKEY(“Item No.”);

SomeTable.SETFILTER(“Document No.”,’=%1’,‘S19225…’)

IF SomeTable.FINDFIRST THEN BEGIN

Count := 0; // Local variable

ItemNo := ‘’ // Local variable

REPEAT

IF Item No <> SomeTable.“Item No.” THEN BEGIN

Count := Count + 1;

ItemNo := SomeTable.“Item No.”;

END;

UNTIL SomeTable.NEXT = 0;

END;

EXIT(Count);

Is there any smarter way of doing a COUNTUNIQUE in Navision?

Scott

Sounds like a good idea, but I’m sorry, there is no such function in Navision.

To do this in Navision, best is to create a table with the unique fields a primary key fields. Then you populate this runtime as a temporary table. When you finished this you can do a normal count on the table.

Temporary tables do not need to be in your license in order to use them in your code.