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

pivot table total mode, workaround with aggr and avg problem for LY

Hello,

As far as I know in pivot table its not possible to choose different total modes for partial sums so I've been trying to come out with some sort of workaround for that. Basically instead of taking sum in total mode, I need to figure out how to get the average.

There are two columns: basket size TY and basket size LY.

For basket size TY I got it working with this expression:

=avg(aggr(sum(D_SPT), Store, Date)).

I can't get LY working, this is one of the expressions that Ive tried

=avg(aggr(sum({$<D_Weekend = {"$(=date(D_Weekend-364))"}>} D_SPT), Store, Date))

I attached my report.

Thank you

1 Solution

Accepted Solutions
Not applicable
Author

I changed the expression to:

=avg({<D_Weekend = {"$(=date(D_Weekend-364))"}>}
aggr(sum({<D_Weekend = {"$(=date(D_Weekend-364))"}>}D_SPT), Store, Date))


You are doing two aggregates in that expression. If you only put the Set Analysis in the interior, it won't work, because the exterior function would still be operating based on the selection, which is the 2010 date. If you put the Set Analysis in both functions, they both will properly evaluate for the selected date - 364.

View solution in original post

2 Replies
Not applicable
Author

I changed the expression to:

=avg({<D_Weekend = {"$(=date(D_Weekend-364))"}>}
aggr(sum({<D_Weekend = {"$(=date(D_Weekend-364))"}>}D_SPT), Store, Date))


You are doing two aggregates in that expression. If you only put the Set Analysis in the interior, it won't work, because the exterior function would still be operating based on the selection, which is the 2010 date. If you put the Set Analysis in both functions, they both will properly evaluate for the selected date - 364.

Not applicable
Author

This makes sense, thank you!