Skip to main content
Announcements
Qlik Community Office Hours - Bring your Ideation questions- May 15th, 11 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sum and average of derived expression?

Hi,

I would like to get sum, mean, standard deviation and count from a derived expression. I tried many different ways, still cannot figure it out by myslef. Please refer to the sample project in the attachment. Any helps will be highly appreciated!!!

Longmatch

1 Solution

Accepted Solutions
swuehl
MVP
MVP

I believe you can get your results using advanced aggregation, using expressions in your text box like:

= 'Total  moving range is: ' & sum(aggr(fabs(count(ID)-above(count(ID))),Month))

and

= 'Average of moving range is: ' & avg(aggr(fabs(count(ID)-above(count(ID))),Month))

You will run into one issue here: aggr() function sorts its dimension values by load order, and load order for Month is mixed up, not in chronological order, for your input data. You can see this if you create a list box for Month and set sort order to load order.

You can correct this is by reading in your Month sorted, if this is not possible, you can create all field values of Month ordered correctly as first load in the script, creating the correct load order. After loading in your data, you can drop the field (only from the first table), if you want.

See attached for my solution.

Regards,

Stefan


View solution in original post

2 Replies
swuehl
MVP
MVP

I believe you can get your results using advanced aggregation, using expressions in your text box like:

= 'Total  moving range is: ' & sum(aggr(fabs(count(ID)-above(count(ID))),Month))

and

= 'Average of moving range is: ' & avg(aggr(fabs(count(ID)-above(count(ID))),Month))

You will run into one issue here: aggr() function sorts its dimension values by load order, and load order for Month is mixed up, not in chronological order, for your input data. You can see this if you create a list box for Month and set sort order to load order.

You can correct this is by reading in your Month sorted, if this is not possible, you can create all field values of Month ordered correctly as first load in the script, creating the correct load order. After loading in your data, you can drop the field (only from the first table), if you want.

See attached for my solution.

Regards,

Stefan


Not applicable
Author

This is what I need, it just works perfectly. Thank you very much. I only need average, standard deviation and sum, so the order is not issue.