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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Limit Dates shown in pivot table

I'm working on creating a trending report for COGS% in a pivot table.  The report has our customers listed down on the left side with the columns being the our fiscal months.  I have three years worth of data however and only want the pivot table to show the most recent 7 months at any given point in time.  I've been told I need to do a set analysis but am unsure of how to incorporate that in to my sum statement. 

Here is the current sum statement:  (Sum({<[Trending]={'Cost of Sales'}>} [Amount]) / sum({<[Trending]={'Revenue'}>} [Amount]))

My date field is named MonthYr and is in the format of mm-dd-yyyy.  Ideally, I want to set up a formula where if 1/31/2016 is the most recent date for MonthYr variable within the data set, that the columns shown in my pivot table are Jan-16, Dec-15, Nov-15, Oct-15, Sep-15, Aug-15, Jul-15.

Thank you in advance for any help provided.

6 Replies
MK_QSL
MVP
MVP

Provide sample data please !

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Something like this:


Sum({<[MonthYr={">=$(=MonthStart(Max(MonthYr),-6))<=$(=Date(Max(Date)))"}, Trending]={'Cost of Sales'}>} [Amount]) / sum({<[MonthYr={">=$(=MonthStart(Max(MonthYr),-6))<=$(=Date(Max(Date)))"}, [Trending]={'Revenue'}>} [Amount])


talk is cheap, supply exceeds demand
ajayrai
Partner - Contributor III
Partner - Contributor III

Create a variable (vPrevSevenMonths) which will contain the 7 months back date and use it in set analysis.

vPrevSevenMonths=MonthStart(AddMonths(max(Month),-7))

Like this.

=Sum({<Date ={"<=$(=vPrevSevenMonths)"}>} FieldName)

Not applicable
Author

I've tried both the methods which have been mentioned above by Gysbert and Ajay to no avail.  As I was unsure if it was related to the various linkage between my main tables, I removed all tables from my query except for 1 which contains InvoiceDate, Amount, and Unit.  Applying the methods above to the field InvoiceDate (as opposed to the previously mentioned MonthYr field) still does not produce any results.  My InvoiceDate field is being loaded in the format of MM/DD/YYYY Hr:Mm:Ss AM; could it be this load format which is causing the issue?

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Could be. Perhaps your MonthYr field contains text values. Try posting a small qlikview document that demonstrates the problem.


talk is cheap, supply exceeds demand
ajayrai
Partner - Contributor III
Partner - Contributor III

Date format should be same on both sides which you are comparing.

Post a sample application or sample excel which contains your dummy data.