Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
trevorcrow
Contributor II
Contributor II

Display Count of Distinct Order Numbers in a Column

Hello Qliksense community!  I am hoping someone might be able to assist me with my question.  I have a table of orders and their current errors.  The way the data is structured there can be multiple error records per order number, resulting in a table that looks like the following:

SOURCE_ORDER_ID ERROR_MESSAGE
1522222 Missing Address
1874666 Missing Payment Information
1544444 Invalid Data
1253232 Missing Payment Information
1253232 Missing Address
1253232 Missing Name

 

I'm wanting to display the row number in a column that shows the row count by distinct order number.  Below is what I'm wanting to display.  Any thoughts on how I can accomplish that?

SOURCE_ORDER_ID ERROR_MESSAGE Unique Order Count
1522222 Missing Address 1
1874666 Missing Payment Information 2
1544444 Invalid Data 3
1253232 Missing Payment Information 4
1253232 Missing Address 4
1253232 Missing Name 4
Labels (1)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

use AutoNumber()

 

Load

SOURCE_ORDER_ID

,ERROR_MESSAGE

,Autonumber(SOURCE_ORDER_ID) as ID

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

4 Replies
BrunPierre
Partner - Master
Partner - Master

Hi, Create a straight table or pivot table with the following

Dimensions: SOURCE_ORDER_ID and ERROR_MESSAGE

Measure: =Aggr(NODISTINCT RowNo(), SOURCE_ORDER_ID)

cristianj23a
Partner - Creator III
Partner - Creator III

Hi, try this code:

myTable:
LOAD SOURCE_ORDER_ID,
ERROR_MESSAGE,
Autonumber(SOURCE_ORDER_ID) as TempID INLINE [
SOURCE_ORDER_ID, ERROR_MESSAGE
1522222, Missing Address
1874666, Missing Payment Information
1544444, Invalid Data
1253232, Missing Payment Information
1253232, Missing Address
1253232, Missing Name
];

TempTable:
LOAD *,
If(Peek('TempID') = TempID, Peek('Unique Order Count'), If(IsNull(Peek('Unique Order Count')), 1, Peek('Unique Order Count')+1)) as 'Unique Order Count'
Resident myTable
Order by TempID;

Drop Table myTable;
DROP Fields TempID from TempTable;

RENAME Table TempTable to myTable;

cristianj23a_0-1690925812700.png

 

Regarts.

 

 

https://www.linkedin.com/in/cristianjorge/
Do not forget to mark as "Accepted Solution" the comment that resolves the doubt.
vinieme12
Champion III
Champion III

use AutoNumber()

 

Load

SOURCE_ORDER_ID

,ERROR_MESSAGE

,Autonumber(SOURCE_ORDER_ID) as ID

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
trevorcrow
Contributor II
Contributor II
Author

This worked perfectly and was very simple to add into my load statement.  Thanks so much everyone!