Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

richters
New 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
MVP
MVP

Re: Formula with fields of two tables in script

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
2 Replies
MVP
MVP

Re: Formula with fields of two tables in script

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
New Contributor III

Re: Formula with fields of two tables in script

Hi,

totally what I thought, thanks a lot!

Community Browser