Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
AWS Degraded - You may experience Community slowness, timeouts, or trouble accessing: LATEST HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

simplify formula

Hello,

My processor is to slow when I use the formulea:

  sum

({<Source={Sales}, GL_1={VOL}>}
if(InYearToDate(EffectiveDate,'01-'&PITPeriod&'-'&PITYear,0,4),
Data))

The database is over 50 million record. Structure as in the attachment.

Does anyone know a why to de-stress my processor?

René


1 Solution

Accepted Solutions
vincent_ardiet
Specialist
Specialist

Hi,

First try to create a variable which contains the value of PITYear and PITPeriod.

If it's still not good.

Then, you can try to create another field which you can use in a set analysis instead of a If.

As you want that your year starts in April, you can add a CorrectedYear in your model (which is 2012 for an effectivedate before April else 2013), and just compare this field with PITYear in a set analysis.

Regards,

Vincent

View solution in original post

5 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

PITPeriod and PITYear are in a data island. That means the expression is calculated over a cartesian product. If there is only one row in that table then you could create a flag field in the script so the if statement can be replaced in your expression.

Load x,y,z,

-1*InYearToDate(EffectiveDate,'01-'& peek('PITPeriod')&'-'& peek('PITYear'),0,4) as IsYTD

from ...;

The expression could then change to sum(({<Source={Sales}, GL_1={VOL}, IsYTD={1}>}Data)


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks,

Not sure what you mean by if there is only one row in the PITYear and PITPeriod data island. There are over 3000 rows in that table.

I use it so users can select a period to view the data.

For exsample see the aftachment.

PIT.JPG

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Well, that data island is most likely responsible for a large part of your performance troubles since it means you need that expensive if statement. Your probably far better off with a master calendar that is properly associated with your other tables. See this discussion: Tutorial - Using Common Date Dimensions and Shared Calendars


talk is cheap, supply exceeds demand
vincent_ardiet
Specialist
Specialist

Hi,

First try to create a variable which contains the value of PITYear and PITPeriod.

If it's still not good.

Then, you can try to create another field which you can use in a set analysis instead of a If.

As you want that your year starts in April, you can add a CorrectedYear in your model (which is 2012 for an effectivedate before April else 2013), and just compare this field with PITYear in a set analysis.

Regards,

Vincent

Not applicable
Author

Thanks! Off course creating a variabel based upon the PIT selection was the answer.

Makes sense now...