Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Partner
Partner

How to trend Current Sales vs Prev Sales, using date as dimension?

Hi,

I have here one of client's requirement, would this be possible? Can we able to trend in one line chart the Current Sales vs Prev Sales, using Date as Dimension? (see attached file)

sales vs prev sales.jpg

NOTE:

Blue Line Dates are Dec 29, 2013 to Jan 7, 2014

Orange Line Dates are Dec 29, 2012 to Jan 7, 2013

What did is that, only date of Blue Line being used as dimension. This the same as getting Sales Revenue of Same Day of Previous Year.

As far as I'm concern, this is not doable, isn't it? If anyone could help, I would appreciate.

Regards,

Bill

Tags (3)
1 Solution

Accepted Solutions
Partner
Partner

Re: Re: How to trend Current Sales vs Prev Sales, using date as dimension?

Hi, Bill Ringer Salalima

The question is, is it really doable?

I believe answer is yes. I would prefer to use for it AsOfTable approach as in article Calculating rolling n-period totals, averages or other aggregations mentioned by Gysbert Wassenaar in his answer.

I believe it gives results conforming to your requirements.

SalesVsPrevSales.png

Look at example in attachment

View solution in original post

16 Replies
Not applicable

Re: How to trend Current Sales vs Prev Sales, using date as dimension?

In Line chart , select :

Dimension;  Date

Expression 1; Sum(${<Year = $(=max(Year))>}Sales)

Expression 2; Sum(${<Year = $(=max(Year)-1)>}Sales)

MVP & Luminary
MVP & Luminary

Re: How to trend Current Sales vs Prev Sales, using date as dimension?

You can try using two expressions:

sum(Sales)

above(sum(Sales)).

This approach does have some drawbacks. See this document for more information: Calculating rolling n-period totals, averages or other aggregations


talk is cheap, supply exceeds demand
manideep78
Valued Contributor

Re: How to trend Current Sales vs Prev Sales, using date as dimension?

Hi Bill Ringer Salalima

Make only date as dimension. (for eg, Jan-2, Jan-3 etc)

Then write two expressions for current year and previous year.

Hope this helps

Regards,

Manideep

Partner
Partner

Re: How to trend Current Sales vs Prev Sales, using date as dimension?

Let's say

For Blue Line, dates are from Dec 29, 2013 to Jan 7, 2014

For Orange Line, dates are from Dec 29, 2012 to Jan 7, 2013

Is this possible to have this chart? The dimension used is Date in Blue Line.

sales vs prev sales.jpg

Partner
Partner

Re: How to trend Current Sales vs Prev Sales, using date as dimension?

Hello Manideep,

The client wants to select dates freely, there should be date ranges selection. Say date selected is from Dec 1, 2013 to Jan 31, 2014.

So what will happen in the in line chart is that:

  • Dates to be shown as Dimension is from Dec 1, 2013 to Jan 31, 2014
  • Sales Revenue will get/calculate daily sales from Dec 1, 2013 to Jan 31, 2014
  • Previous Sales Revenue will get/calculate sales from Dec 1, 2012 to Jan 31, 2013


Meaning, data points for Previous Sales Revenue will be within the data points of Sales Revenue.


I know this requirement is kinda tricky, but I hope there's solution on this!



Regards,

Bill

vikasmahajan
Esteemed Contributor

Re: Re: How to trend Current Sales vs Prev Sales, using date as dimension?

Dear Bill,

You require like wise comparison for  current date vs last yr same day date , Please refer demo attached.

Best of Luck.

Vikas

Partner
Partner

Re: Re: How to trend Current Sales vs Prev Sales, using date as dimension?

Hello Vikas,

I thought attached file could have sample report like what is being required. Anyway, thanks for that info.

vikasmahajan
Esteemed Contributor

Re: How to trend Current Sales vs Prev Sales, using date as dimension?

Dear Bill,

Add this variables in calendar ,

  num(Year(TempDate)&num(Month(TempDate),'00')) as YEAR_MONTH, // Link between tables for previous month / year selection

     num((Year(TempDate)-1)&num(Month(TempDate),'00')) AS YEAR_MONTH_PREVIOUS, // Link between tables for previous month / year selection

     num((Year(TempDate)-2)&num(Month(TempDate),'00')) AS P_YEAR_MONTH_PREVIOUS

Use this variables in set analysis

for CY

SUM({$<FiscalYear={$(=max(FiscalYear))}>} [Sales Amount])

for LY Same Date

( SUM({$< FiscalYear={$(=max(FiscalYear)-1)},YEAR_MONTH=p(YEAR_MONTH_PREVIOUS),[Posting Date]={'<=$(vLMaxDate)'},FinancialYear=,MonthName=>}[Sales Amount])

Hope this helps you

Vikas

Partner
Partner

Re: How to trend Current Sales vs Prev Sales, using date as dimension?

Hi,

I appreciate your effort but I tried to apply, I'm still getting the same output as mine... The requirement is to have like this output (see image). The question is, is it really doable? As you can see in X-axis, date ranges from Dec 29, 2013 to Jan 7, 2014. So here, two Years are involve.

Blue Line is data of Sales as of Dec 29, 2013 to Jan 7, 2014

Orange Line is data of Sales as of Dec 29, 2012 to Jan 7, 2013


I would more appreciate if you could provide sample report that display like chart below? My apology of posting the same image.

sales vs prev sales.jpg