Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need Previous Month Details using this query...

Hi Guys,

i been asked by get previous month of details using this query , help me out...

(((sum({<SalesFy=,Quarter=,Month=,Week=,BILLDATE=,DateNum={">=$(=Num(MonthStart(Max(DateNum),-1)))<=$(=num(MonthEnd(max(DateNum))))"},BILLDETAILENTRYTYPE = {'B'}, BILLCANCELLED = {'N'}, BILLESTIMATE = {'N'}>}BILLDETAILAMOUNT)

-

SUM({<SalesFy=,Quarter=,Month=,Week=,BILLDATE=,DateNum={">=$(=Num(MonthStart(Max(DateNum),-1)))<=$(=num(=MonthEnd(max(DateNum))))"},BILLDETAILENTRYTYPE = {'B'}, BILLCANCELLED = {'N'}, BILLESTIMATE = {'N'}>}BILLDISCOUNT))

-

(sum({<SalesFy=,Quarter=,Month=,Week=,BILLDATE=,DateNum={">=$(=Num(MonthStart(Max(DateNum),-1)))<=$(=num(=MonthEnd(max(DateNum))))"},BILLDETAILENTRYTYPE = {'R'}, BILLCANCELLED = {'N'}, BILLESTIMATE = {'N'}>}BILLDETAILAMOUNT))

-

(sum({<SalesFy=,Quarter=,Month=,Week=,BILLDATE=,DateNum={">=$(=Num(MonthStart(Max(DateNum),-1)))<=$(=num(=MonthEnd(max(DateNum))))"}, BILLDETAILENTRYTYPE = {'O'}, BILLCANCELLED = {'N'}, BILLESTIMATE = {'N'},URDPURCHASE = {'Y'}>}BILLDETAILAMOUNT))

+

SUM({<SalesFy=,Quarter=,Month=,Week=,BILLDATE=,DateNum={">=$(=Num(MonthStart(Max(DateNum),-1)))<=$(=num(=MonthEnd(max(DateNum))))"},BILLDETAILENTRYTYPE = {'B'}, BILLCANCELLED = {'N'}, BILLESTIMATE = {'N'}>}BILLDETAILOTHERSTONECHARGE)

-

SUM({<SalesFy=,Quarter=,Month=,Week=,BILLDATE=,DateNum={">=$(=Num(MonthStart(Max(DateNum),-1)))<=$(=num(=MonthEnd(max(DateNum))))"},BILLDETAILENTRYTYPE = {'R'}, BILLCANCELLED = {'N'}, BILLESTIMATE = {'N'}>}BILLDETAILOTHERSTONECHARGE)

-

SUM({<SalesFy=,Quarter=,Month=,Week=,BILLDATE=,DateNum={">=$(=Num(MonthStart(Max(DateNum),-1)))<=$(=num(=MonthEnd(max(DateNum))))"},BILLDETAILENTRYTYPE = {'O'}, BILLCANCELLED = {'N'}, BILLESTIMATE = {'N'},URDPURCHASE = {'Y'}>}BILLDETAILOTHERSTONECHARGE))

)/(AmtFlag)

Thanks in advance

3 Replies
sunny_talwar

What is this query calculating right now? Current Month?

Not applicable
Author

Yeah Sunny it evaluates current month but, this question been solved...

Thanx for your concern....

sasikanth
Master
Master

HI,

i think your current query is calculating both current and previous months related data

">=$(=Num(MonthStart(Max(DateNum),-1))) --> Previous Month start


<=$(=num(=MonthEnd(max(DateNum))))" --> current Month end


if you need to calculate only previous month related data then use this


">=$(=Num(MonthStart(Max(DateNum),-1))) <=$(=num(=MonthEnd(max(DateNum),-1)))"