Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Comparing Current Month and Previous Month Sales

Hi,

I wanted to compare the total sales amount of the current month to the total sales amount of the previous month.

I tried using the below expression, but the previous month script does not seems to work. It will still display as the current month figure:

SET ThousandSep=',';

SET DecimalSep='.';

SET MoneyThousandSep=',';

SET MoneyDecimalSep='.';

SET MoneyFormat='$#,##0.00;($#,##0.00)';

SET TimeFormat='h:mm:ss TT';

SET DateFormat='MM/DD/YYYY';

SET TimestampFormat='MM/DD/YYYY h:mm:ss[.fff] TT';

SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';

SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';

LOAD Year,

     Month,

     Product,

     Sales,

     Date(Date#(Left(FileBaseName(), 10), 'MM/DD/YYYY')) As FileDate

FROM

(biff, embedded labels, table is Sheet1$);

Current Month Expression:

= sum({<FileDate = {">=$(=MonthStart(Today()))<= $(=MonthEnd(Today()))"}>}Sales)

Previous Month Expression:

= sum({<FileDate = {">=$(=MonthStart(AddMonths(Today(),-1)))<= $(=MonthEnd(AddMonths(Today(),-1)))"}>}Sales)

Please help. Appreciate your time and help in this.

Thank you.

42 Replies
stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Quarters can be derived by using the following code:

'Q' & Ceil(Month(today() + RowNo()) / 3) as Quarter

You can then use Quarter in Set Analysis just like the other date fields.

The best place to find other tutorial bits is on my blog:

http://www.quickintelligence.co.uk/qlikview-blog/

There are separate pages for downloads and videos:

http://www.quickintelligence.co.uk/qlikview-examples/

http://www.quickintelligence.co.uk/qlikview-videos/

To by notified of new blog posts you can subscribe to the blog, I can also be found on Twitter and LinkedIn - where I tend to announce new posts.


Thanks for asking!


Steve

Not applicable
Author

Thank u so Much Steve ....Thanks for Ur time

Not applicable
Author

Very informative and works perfectly. Thank you Steve!