Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
richters
Partner - Contributor III
Partner - Contributor III

Formula with fields of two tables in script

Hi all,

I believe I have a very simple problem.

I have got two tables and want to calculate sth. with one field of each of them. They are connected by the ID.

Table1:

------------

ID

Name

Days

Table2:

------------

ID

DaysOff

Now I want to subtract Days-DaysOff as a new field in Table1.

So I started like this:

left join (Table1) LOAD ID, Days-DaysOff as TotalDays resident Table2;

I also switched Table1 and Table2 but I dont get it. TotalDays should be a field of Table1. In the best case I do not want to JOIN them. I know this would be a solution.

Thanks in advance!

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

You are correct, both fields need to be in Table1 before you can calculate TotalDays. The way to do it is like this

Join (Table1)

LOAD ID,

          DaysOff

Resident Table2;

Join (Table1)

LOAD ID,

          Days - DaysOff As TotalDays

Resident Table1;

DROP Field DaysOff from Table1;

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

2 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

You are correct, both fields need to be in Table1 before you can calculate TotalDays. The way to do it is like this

Join (Table1)

LOAD ID,

          DaysOff

Resident Table2;

Join (Table1)

LOAD ID,

          Days - DaysOff As TotalDays

Resident Table1;

DROP Field DaysOff from Table1;

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
richters
Partner - Contributor III
Partner - Contributor III
Author

Hi,

totally what I thought, thanks a lot!