Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Delete dublicate rows group by some field in loadscript

Good day!

In my model i have following fields:

rowno(),

Id,

Name,

Customer_id

Main_field.

My result table:

     

rowno()IdNameCustomer_idMain_field
122Name1196Main1
222Name2196Main1
322Name1196Main1
422Name2197Main1

What i need: Get result table, which has no dublicate rows by Customer_Id:

    

rowno()IdNameMain_field
122Name1Main1
222Name2Main1

Is it possible?

Model and source file in attachment.

Thanks.

1 Solution

Accepted Solutions
maxgro
MVP
MVP

RESULT

1.png

SCRIPT

Table:

load

rowno() as rn,

*

FROM

Test.xlsx

(ooxml, embedded labels, table is Sheet1)

;

FinalTable:

load *, RowNo();

NoConcatenate

load Id, Customer_id, Name, Main_field

Resident Table

where Customer_id <> Peek(Customer_id)

order by Customer_id, rn;

DROP Table Table;

View solution in original post

5 Replies
Not applicable
Author

You can't use both DISTINCT & ROWNO() in same load statement.

Hi Try like Below:

Temp:

load Distinct

  Id,

  Name,

  Main_field

FROM Test.xlsx (ooxml, embedded labels, table is Sheet1) ;

Table:

LOAD RowNo() , * Resident Temp;

DROP Table Temp;

Anonymous
Not applicable
Author

For what i wrote this post:

my task is to concat different names for my Id.

Table:

load

*

FROM

Test.xlsx

(ooxml, embedded labels, table is Sheet1)

;

New_table:

load

Id,

Concat(Name,'-') as NewName

Resident Table

Group by Id;

DROP Table Table;

In result i get NewName Name1-Name1-Name2-Name2, but i need: Name1-Name2

Not applicable
Author

Use Distinct Qualifier Inside Concat function like below:

Table:

load

*

FROM

Test.xlsx

(ooxml, embedded labels, table is Sheet1)

;

New_table:

load

Id,

Concat(DISTINCT Name,'-') as NewName

Resident Table

Group by Id;

DROP Table Table;

maxgro
MVP
MVP

RESULT

1.png

SCRIPT

Table:

load

rowno() as rn,

*

FROM

Test.xlsx

(ooxml, embedded labels, table is Sheet1)

;

FinalTable:

load *, RowNo();

NoConcatenate

load Id, Customer_id, Name, Main_field

Resident Table

where Customer_id <> Peek(Customer_id)

order by Customer_id, rn;

DROP Table Table;

Anonymous
Not applicable
Author

Thank you!

it's what i need.