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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

replacing if statements using flags help needed!

Hi guys,

I have recently read Oleg's thread on replacing if statements with flags(which I found very informative). I tried applying this concept to the chart I constructed using the following expresssions below. AS you can see there is 1 main chart expression containing two variables which are both listed below also. Furthermore, there is a background colour expression using nested if statements. It is quite a complex expression with alot of set analysis within it. Can anyone think of a way to simplify this as it takes a very long time to load this chart.

expressions:

General Chart expression:
if ($(vUptimeForSelectedMonth) = 1, 0, $(vUptimeForSelectedMonth))


UptimeForSelectedMonth Variable:
round(if((count({$<MonthYear= , Day = , Week = , LastWeek =, StartDate = >}IncidentId)=0) OR (IsNull($(vMonthlyNetworkDays))),
1,
1-sum({$<MonthYear= , IncidentId = , Day = , Week = , LastWeek =, StartDate = , LastWeek = >} sevimpact)/
$(vMonthlyNetworkDays)),0.00001)

vMonthlyNetworkdays variable:
(networkdays(
monthstart(min({$<MonthYear= , IncidentId = , Day = , Week = , LastWeek = , StartDate = >}StartDate)),
monthend( max({$<MonthYear= , IncidentId = , Day = , Week = , LastWeek =, StartDate = >}StartDate))
)*60*24)


background colour expression:
if ( $(vUptimeForSelectedMonth) >=0.9995,
rgb(51,204,102),

if( $(vUptimeForSelectedMonth) <0.9990,
rgb(255,0,0),
rgb(255,128,0)
)
)

Thanks in advance,
bc

6 Replies
Not applicable
Author

I can only suggest possibly creating a flag with a inline load at script level or perhaps using visual cues instead of background expressions.

Not applicable
Author

Hi,

the idea behind flags is to flag data-records within your load-script.
Doing so these values will be available within your datamodel and you can use these data like other fields; this would enhance the performance, doing everything with variables within your document and with ad-hoc calculations will under circumstances slow down your performance ...

What is your question? How to change your variables and chart-expressions to flags?

Best regards
Stefan

Not applicable
Author

Hi Stefan,

Yes, I'm looking at a way in which flags could possibly be created instead of variable and expression in my script so that the performance of the charts improves. Currently it is very slow!

Thanks

bc

johnw
Champion III
Champion III

Since your vUptimeForSelectedMonth depends on your selections, there is no way to set it in the script.

However, off hand, it seems to me that your uptime for each month shouldn't be changing based on selections. If so, you should be able to load a simple table with the month and the uptime.

Not applicable
Author

Hi John,

The expression does change with selections such as choosing your department or team but shouldn't be affected by date selections etc. Therefore I think it rules that option of the simple table out unfortunately?

Thanks for comments!

johnw
Champion III
Champion III

Ah, OK. Yeah, unfortunately, I think that does rule out creating a simple table with the results.

Maybe there's a way other than set analysis to disconnect some of the data from the other selections, but I'm not thinking of a way.

It looks like the big performance bottleneck is a serious amount of recalculation of the same values. You refer to uptime four times, and for each of those you refer to net work days twice. That's up to eight calculations of net work days.

So maybe there are ways to economize. For instance, how critical is it that 100% uptime is displayed as 0 instead of as 100%? Displaying 100% as 100% would get rid of one of the uptime calculations. Or how about hidden columns? If you could have an uptime column, you should be able to refer to the column name instead of to the variable, and thus only calculate uptime once. You could then do the same thing for the net work days.