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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlik4Life
Contributor
Contributor

AGGR and StDev within parameters for Set Analysis

I am attempting to write an expression that will run an average and Standard Deviation*3 for every Code and only return the total Days that are below that Codes sum(Avg+StDev*3). The expression is working but I am not getting the desired result it is evaluating the Standard Deviation for the entire set instead of each Code. In the end I need a KPI that has the total days from each Code bucket.

 

Sum({<Value={"<=$(=(Sum(Value)/count(distinct Key)) + (StDev(Aggr(Sum(Value)/Count(distinct Key), Code, Key))*3))"}>}Days)

3 Replies
marcus_sommer
MVP
MVP

$(= anything) creates an adhoc-variable which is evaluated once before the chart is calculated and there applied to each row. You could try to change your expression in this way:

Sum({<Days={"=Value<=(Sum(Value)/count(distinct Key)) + (StDev(Aggr(Sum(Value)/Count(distinct Key), Code, Key))*3)"}>}Days)

- Marcus

Qlik4Life
Contributor
Contributor
Author

It is a great thought, and is why I was getting a flat number instead of an adjustable number based on the code, but it didn't solve my issue. The calculation is still not correct.

marcus_sommer
MVP
MVP

Just ensure that each expression-part of the condition returned the expected results within your object. This means to create further calculations for:

Sum(Value)
count(distinct Key)
StDev(Aggr(Sum(Value)/Count(distinct Key), Code, Key))*3

If not they might need further set analysis and/or TOTAL statements and/or different dimensions within the aggr().

- Marcus