Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
johnnyjohn
Creator
Creator

Adding values from another table based on ID

So say I have the following files

Table1

johnnyjohn_0-1603957034948.png

Table2

Capture.PNG

I am loading them into Qliksense. 

Basically, when loading Table2, I am trying to add values from Table1 in the following way:

  • For each ID (a1, a2, etc...), I need to add a row to Table2 using values from Table1
  • In Table1, I'm always going to have an ID show up once, and it will have a value associated to it (here called extra_value). 
  • In my Table2, I need to add, for each ID, at max(depth + 1), the value found in Table1 with the corresponding ID.

i.e. the extra_value of a1 in Table1 would be added to Table2 under the ID a1; and with value=0.54 and depth=3

so the final table would look like this (rows added are highlighted)

 
 

Capture.PNG

Stumped on this one, any help would be appreciated

 

Labels (1)
6 Replies
agigliotti
Partner - Champion
Partner - Champion

Hi @johnnyjohn ,

You could use a simple "concatenate" statement like below:

load * from Table1;
concatenate
load * from Table2;

I hope it helps.
Andrea

MayilVahanan

Hi @johnnyjohn 

Try like below

T1:
LOAD * Inline
[
id, value, depth
a1, 0.12, 1
a1, 0.23, 2
a2, 0.15, 1
a2, 0.87, 2
];

Concatenate(T1)
Load * Inline
[
id,extra_value
a1, 0.54
a2, 0.87
];

Load id, if(IsNull(value), extra_value, value) as value, If(IsNull(depth), Peek('depth')+1, depth) as depth Resident T1
order by id;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Brett_Bleess
Former Employee
Former Employee

@MayilVahanan You have received two very good possible solutions, we would appreciate it if you would return to the thread and use the Accept as Solution button on the post(s) that did help, or if you did something different, you can create a new post about that and then use the button on that post to mark the thread as solved.  If you require further help, please leave an update.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
MayilVahanan

Hi @Brett_Bleess 

I can't accept the solution and close this thread , because it's not create by me 😉

Hi @johnnyjohn 

Can you please close this thread.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
edwin
Master II
Master II

another solution that will include the depth column but not using peek

noconcatenate
extra:
load ID, max(Depth) as Depth resiodent table2 group by ID;

inner join (extra) load ID, ExtraValue as Value resident table1;

concatenate(table2) load ID, Value, Depth resident extra;

drop table extra;

 

Brett_Bleess
Former Employee
Former Employee

@MayilVahanan My apologies, I miss-clicked and got your ID instead of @johnnyjohn very sorry about that!  Thanks for flagging it to @johnnyjohn to respond and close it out.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.