Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to create a new column filled with '1'

Hi all,

my short question:

how can i create a new column filled with '1' in every row in an existing table.

I need it to count my data without the 'count' command.

best regards

Philipp

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Or if your table already exists (and you don't wanna change the LOAD statement - or you can't), use this:

JOIN (ExistingTable)

LOAD 1 AS RowCounter

AUTOGENERATE 1;

We should test which is faster: another LOAD RESIDENT or a simple JOIN. Massimo's original table LOAD moditifcation will beat everything else...

View solution in original post

8 Replies
Not applicable
Author

my short answer: just type 1 into a new expression

maxgro
MVP
MVP

if I understand, in the load script

load

     field,

     ....

     1 as newfield,

     ....

from

     .....

but why you don't want count?

Not applicable
Author

Sorry but i don't understand your idea... i need a column named 'DataCounter' that have as much as rows like the other columns in this table. But 'DataCounter' has a '1' in every row.

simospa
Partner - Specialist
Partner - Specialist

Another short answer 🙂

LOAD      field1

               field2,

               ...,

               fieldn,

               1 as myCounter

FROM ...

S.

MayilVahanan

Hi

Try like this

Load *, 1 As DataCounter

from sourcetable;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

Load *, 1 as DataCounter from Table1;

Not applicable
Author

This is why the long more detailed question is more helpful

You talk about a new column which sounds like a new expression in a chart, creating a new expression with just '1' in it will do just that in a chart.

Actually though it sounds like you a looking for a new field in your data model, now you have given a bit more detail.

For that you can simply add a new field to your load

1 As DataCounter

hope that helps

Joe

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Or if your table already exists (and you don't wanna change the LOAD statement - or you can't), use this:

JOIN (ExistingTable)

LOAD 1 AS RowCounter

AUTOGENERATE 1;

We should test which is faster: another LOAD RESIDENT or a simple JOIN. Massimo's original table LOAD moditifcation will beat everything else...