Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Aryasmank
Contributor III
Contributor III

Moving AGGR Calculation from front-end to backend

Hi All, 

I want to move my AGGR calculation to backend from from-end.

Expression : aggr(count({<status={'Valid'}, ROD={"$(Date(max(ROD)))"}>} distinct id_pd), Date)

there are two tables :

 table1:   columns -->  id, ROD,  id_pd

table2:  columns --> id, Date, status

how this expression can be done in load script .

--Mayank

 

     

Labels (2)
1 Solution

Accepted Solutions
starke_be-terna
Partner - Contributor III
Partner - Contributor III

Hi Mayank!

You need to first join both sources in your script, before you can aggregate data using "group by".

AGGR_prep:
load * from table1; // LOAD table1 from source

left join(AGGR_prep) // Might need other join() operation depending on use-case
load * from table2; // join table2 from source

// generate aggregated data
AGGR_table:
load
  Date,
  count(distinct id_pd) as id_pd_count
resident
  AGGR_prep
group by
  Date
;

// get rid of helper table
drop table AGGR_prep;

Be aware of the following:
By generating your count in the Qlik script you can only use the data granularity you used in the generation process (in our example Date).
Let's say you add the dimension "Department" to one of your tables. The current script I provided would not discriminate between different Departments, so when the end user makes a Department selection, the numbers would not change. This needs to be kept in mind for future changes of your application.

Best regards,
Benjamin

View solution in original post

2 Replies
starke_be-terna
Partner - Contributor III
Partner - Contributor III

Hi Mayank!

You need to first join both sources in your script, before you can aggregate data using "group by".

AGGR_prep:
load * from table1; // LOAD table1 from source

left join(AGGR_prep) // Might need other join() operation depending on use-case
load * from table2; // join table2 from source

// generate aggregated data
AGGR_table:
load
  Date,
  count(distinct id_pd) as id_pd_count
resident
  AGGR_prep
group by
  Date
;

// get rid of helper table
drop table AGGR_prep;

Be aware of the following:
By generating your count in the Qlik script you can only use the data granularity you used in the generation process (in our example Date).
Let's say you add the dimension "Department" to one of your tables. The current script I provided would not discriminate between different Departments, so when the end user makes a Department selection, the numbers would not change. This needs to be kept in mind for future changes of your application.

Best regards,
Benjamin

Aryasmank
Contributor III
Contributor III
Author

Hi Benjamin, 

Thank you so much , I really helpful.

--Mayank