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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

"Set analysis" in a chart/pivot

I have a dataset that looks like this:

MonthSales TeamSales repSum

1

AX

400

1AY200
1BZ300
1BQ500
2AX300
2AY400
2BZ600
2BQ700
3AX800
3AY100
3BZ90
3BQ5

for each row I want to show the sum of the previous month, for that sales rep and sales team.

so it would look like this:

MonthSales TeamSales repSumSum last month

1

AX400

300

1AY

200

400
1BZ300600
1BQ500700
2AX300800
2AY400100
2BZ60090
2BQ7005
3AX800(and so on)
3AY100
3BZ90
3BQ5

the real data is ofcourse more complicated and a few more dimensions.. and needs to work in a pivot not just straight table.

I've tried twenty different set-analysis ideá (above/below does not work in a pivot where user can open and close dimensions)

1 Solution

Accepted Solutions
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

For a universal solution that could work in any chart and any calculation, you need to create the "As of Date" table, where you can define relationships between the current month and the prior month using Flags. Then, the calculation becomes rather simple.

You can find several free sources that describe how to build and use the "As of Date" table, including my blog article:

QlikView Blog Q-Tip #4 How to Use "As of Date" table | Natural Synergies

If you'd like a bit deeper coverage, I'd recommend to read about it in my new book QlikView Your Business. We also teach this and many other advanced techniques at the Masters Summit for Qlik.

Cheers,

Oleg Troyansky

View solution in original post

6 Replies
stephenedberkg
Creator III
Creator III

if you are using master calendar try this

=sum({< Years={$(=Max(Years))},MonthId={$(=Max(MonthId) -1)}>}Sales)

Not applicable
Author

Problem is Max(MonthID) -1 only works for the last month

I want this to work over several months (or even years)

I have all the months in the report already mapped up with an "ID" from 1 to 99 so year thing is not needed.

what I'm after is a generic expression like:

sum(Sales) where MonthID = MonthID-1

marcus_sommer

The open/close option could be disabled (tab presentation) and so above() will work. Otherwise I think you will need for each month an own expression-column and to remove the month-dimension from the pivot.

- Marcus

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

For a universal solution that could work in any chart and any calculation, you need to create the "As of Date" table, where you can define relationships between the current month and the prior month using Flags. Then, the calculation becomes rather simple.

You can find several free sources that describe how to build and use the "As of Date" table, including my blog article:

QlikView Blog Q-Tip #4 How to Use "As of Date" table | Natural Synergies

If you'd like a bit deeper coverage, I'd recommend to read about it in my new book QlikView Your Business. We also teach this and many other advanced techniques at the Masters Summit for Qlik.

Cheers,

Oleg Troyansky

Not applicable
Author

Thank Oleg. Did some small scale test and it works like a charm.

Was begining to think Id have to reload all the data for each month as "previous months amount".

stephenedberkg
Creator III
Creator III

try this


=sum({< Years={$(=Max(Years))},MonthId={$(=Max(MonthId) -1)},Month=>}Sales)