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: 
Not applicable

Generation of new filed from 2 fields loaded by resident statement

Hi experts

I have the following problem:

In my script I generate 2 fields like the following:

Load

    jobnr,

    sum(Rohertrag) as Rohertrag_total_AP,

    sum(VK_soll) as VK_soll_total_AP

resident job where Gesellschaft = 'AP' group by jobnr;

and

Load

    jobnr,

    sum(Rohertrag) as Rohertrag_total_APVJ,

    sum(VK_soll) as VK_soll_total_APVJ

resident job where Gesellschaft = 'AP' AND datum_auftrag < Date(AddYears(Today(),-1)) group by jobnr;

Now I would like to calculate Rohertrag_total_AP/Rohertrag_total_APVJ as a new field, say X. How is this done? If I enter another load statement I do not get an error. But the new field does not appear.

Thank you for your help!

Jan

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

To enter expressions click 'Advanced Mode' (Erweiterter Modus on your dialog). This will take you to the normal expressions dialog where you can enter expressions in the same way as other charts.

HTH

Jonathan

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

View solution in original post

10 Replies
alexandros17
Partner - Champion III
Partner - Champion III

In the front end (Chart) you can do it in expression without problems,

in script you have to join the tables, the resulting table will have both the field then you can divide them

Hope it helps

Not applicable
Author

Hi Alessandro

Thank you for your help

Problem with the chart is, I would like to use a point diagramm. This does not allow me to calculate values.

ScreenShot124.jpg

The chart is of course the way I would prefer to solve the problem, too.

Best

Jan

alexandros17
Partner - Champion III
Partner - Champion III

So the only way is to join table

Not applicable
Author

Hi Alessandro

Sorry to bother you again. Can I join resident ables the same way I join other tables? I also do different seclections after the resident statement.

Thank you for your help!

Jan

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

To enter expressions click 'Advanced Mode' (Erweiterter Modus on your dialog). This will take you to the normal expressions dialog where you can enter expressions in the same way as other charts.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
alexandros17
Partner - Champion III
Partner - Champion III

Resident can be used as normal tables, generally is always (when is possible) better to compute script side expression to reduce execution time

Not applicable
Author

Hi Jonathan

I do not seem to find this option. Under which caption is it located?

Best

Jan

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

Temp:

Load

    jobnr,

    sum(Rohertrag) as Rohertrag_total_AP,

    sum(VK_soll) as VK_soll_total_AP

resident job where Gesellschaft = 'AP' group by jobnr;

LEFT JOIN(Temp)

Load

    jobnr,

    sum(Rohertrag) as Rohertrag_total_APVJ,

    sum(VK_soll) as VK_soll_total_APVJ

resident job where Gesellschaft = 'AP' AND datum_auftrag < Date(AddYears(Today(),-1)) group by jobnr;

Data:

LOAD

*,

Rohertrag_total_AP/Rohertrag_total_APVJ AS NewField

FROM Temp;

DROP TABLE Temp;

Hope this helps you.

Regards,

Jagan.

Kushal_Chawda

Data:

Load

    jobnr,

    sum(Rohertrag) as Rohertrag_total_AP,

    sum(VK_soll) as VK_soll_total_AP

resident job where Gesellschaft = 'AP' group by jobnr;

Join

Load

    jobnr,

    sum(Rohertrag) as Rohertrag_total_APVJ,

    sum(VK_soll) as VK_soll_total_APVJ

resident job where Gesellschaft = 'AP' AND datum_auftrag < Date(AddYears(Today(),-1)) group by jobnr;

Final:

NoConcatenate

LOAD *,

Rohertrag_total_AP/Rohertrag_total_APVJ as X

Resident Data;

DROP Table Data;