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

How to do incremental load on Years based data

Hi all, I

have data like below in the example:

I have taken just for sample data like below, actual data having more fields and Dimensions are repeatative.

I want to load data from B-table excluding A-Table Years data.(here in the example i want to get 5-records from A table, 3-records from B-Table's 2014,2017 years data)

In my actual data i have much data but sample purpose i have given like this.

Can you please give code and or QVW file, that will help.

A:

Load * INLINE [

Year,Dept,Sales

2016,IT,20343

2011,Mec,545

2018,FA,32432

2016,FA,2343

2018,RnD,2343

]


Concatenate(A)

B:

Load * INLINE [

Year,Dept,Sales

2014,IT,20343

2016,Mec,545

2017,IT,32432

2017,FA,2343

2018,SA,2343,

2018,LD,3454

]

Want to get result as below:

Year,Dept,Sales

2016,IT,20343

2011,Mec,545

2018,FA,32432

2016,FA,2343

2018,RnD,2343

2014,IT,20343

2017,IT,32432

2017,FA,2343

Thanks,

Kumar

1 Solution

Accepted Solutions
chrismarlow
Specialist II
Specialist II

I thought not exists as well, but think it fails to pick up the second 2017 record, how about this;

A:
Load * INLINE [
Year,Dept,Sales
2016,IT,20343
2011,Mec,545
2018,FA,32432
2016,FA,2343
2018,RnD,2343
];

DistinctYear:
Load distinct
[Year]
resident A;

ConcatYears:
Load
Concat([Year],',') as Years
Resident DistinctYear;

Let Years=peek('Years');

Concatenate(A)
Load * INLINE [
Year,Dept,Sales
2014,IT,20343
2016,Mec,545
2017,IT,32432
2017,FA,2343
2018,SA,2343
2018,LD,3454
] where match([Year],$(Years))=0;

drop table DistinctYear, ConcatYears;

Or am I over complicating?

Regards,

Chris.

View solution in original post

6 Replies
dplr-rn
Partner - Master III
Partner - Master III

Use not exists. See below

A:

Load * INLINE [

Year,Dept,Sales

2016,IT,20343

2011,Mec,545

2018,FA,32432

2016,FA,2343

2018,RnD,2343

];

Load * INLINE [

Year,Dept,Sales

2014,IT,20343

2016,Mec,545

2017,IT,32432

2017,FA,2343

2018,SA,2343,

2018,LD,3454

]

where not Exists(Year);

chrismarlow
Specialist II
Specialist II

I thought not exists as well, but think it fails to pick up the second 2017 record, how about this;

A:
Load * INLINE [
Year,Dept,Sales
2016,IT,20343
2011,Mec,545
2018,FA,32432
2016,FA,2343
2018,RnD,2343
];

DistinctYear:
Load distinct
[Year]
resident A;

ConcatYears:
Load
Concat([Year],',') as Years
Resident DistinctYear;

Let Years=peek('Years');

Concatenate(A)
Load * INLINE [
Year,Dept,Sales
2014,IT,20343
2016,Mec,545
2017,IT,32432
2017,FA,2343
2018,SA,2343
2018,LD,3454
] where match([Year],$(Years))=0;

drop table DistinctYear, ConcatYears;

Or am I over complicating?

Regards,

Chris.

Anonymous
Not applicable
Author

Hi Dilip,

it is giving the below result:

Year Dept Sales
2016FA2343
2018FA32432
2014IT20343
2016IT20343
2017IT32432
2011Mec545
2018RnD2343

but i want like below: (missing 2017 record from B-Table)

Year,Dept,Sales

2016,IT,20343

2011,Mec,545

2018,FA,32432

2016,FA,2343

2018,RnD,2343

2014,IT,20343

2017,IT,32432

2017,FA,2343


Please check another method if you get idea.

Thanks,

Kumar

dplr-rn
Partner - Master III
Partner - Master III

Good point i always forget that about no exists

Anonymous
Not applicable
Author

you are correct 🙂

Thank you Chris.

it is working, Good.

No doubt working perfectly, but let us think easy one also if we get any.

Thanks,

Ravi

chrismarlow
Specialist II
Specialist II

If it is slow on your set of data you can try an approach with joining a flag;


A:
Load * INLINE [
Year,Dept,Sales
2016,IT,20343
2011,Mec,545
2018,FA,32432
2016,FA,2343
2018,RnD,2343
];

DistinctYear:
Load distinct
[Year]
resident A;

B:
NoConcatenate
Load * INLINE [
Year,Dept,Sales
2014,IT,20343
2016,Mec,545
2017,IT,32432
2017,FA,2343
2018,SA,2343
2018,LD,3454
];

left join (B)
Load
[Year],
1 as flag
Resident DistinctYear;

Concatenate (A)
Load
Year,
Dept,
Sales
Resident B
Where isnull(flag);

drop tables DistinctYear, B;

Cheers,

Chris.