Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

ydelreal
New Contributor

How to show data for previous month in Qlik Sense

Hi,

I am trying to show only last month data.

Example:

Today's date is 10/11/18, which means we are in October. Because it is October, I want it to show me all the data records for the month of September.

Currently my formula is only for the past 30 days, but this is not ideal since it takes in today's date and only subtracts 30.

Count({< [Closed Date] = {"=[Closed Date] >= Today() - 30"} >} [Record ID])

Thanks

9 Replies
dilipranjith
Valued Contributor II

Re: How to show data for previous month in Qlik Sense

Do you have a master calendar setup on Closed date?

if/when you do use set analysis something like Month= {"Month(today())"}

ydelreal
New Contributor

Re: How to show data for previous month in Qlik Sense

No, I don't. I just have the autogenerated calendar options.

dilipranjith
Valued Contributor II

Re: How to show data for previous month in Qlik Sense

Autogenerated one should have a month field too usually .

If not use the master calendar script from

Better Calendar Scripts | Qlikview Cookbook

ydelreal
New Contributor

Re: How to show data for previous month in Qlik Sense

It does. So what would you reccommend the set analysis to look like?

OmarBenSalem
Esteemed Contributor

Re: How to show data for previous month in Qlik Sense

Use the addMonths, MonthStart and MonthEnd Functions, it'll be sthing like this:

sum( {<Month,Date={">=$(=MonthStart(AddMonths(max(Date),-1)))<=$(=MonthEnd(AddMonths(max(Date),-1)))"}>}Measure)

What this does; if u select 23/09/2018 for example; it will show u the data for

the dates between 01/08/2018 and 31/08/2018

Hope this helps

dilipranjith
Valued Contributor II

Re: How to show data for previous month in Qlik Sense

Something like below

Month={"$(=Month(Today()) )"}, Year={"$(=Year(Today()) )"}

or

[Closed Date] ={">=$(=MonthStart(Today()))"}>}

dilipranjith
Valued Contributor II

Re: How to show data for previous month in Qlik Sense

Any luck?

close the thread if it helped

ydelreal
New Contributor

Re: How to show data for previous month in Qlik Sense

I used the formula but it doesn;t work. It shows me "0" even though the count should be 10.

I added in the auto generated month into "Month" and then I added Record ID to "measure".

sum( {<[Date/Time Closed.autoCalendar.Month],Date={">=$(=MonthStart(AddMonths(max(Date),-1)))<=$(=MonthEnd(AddMonths(max(Date),-1)))"}>}[Record ID])

Re: How to show data for previous month in Qlik Sense

How about this?

Count({< [Closed Date] = {"$('>=' & Date(Max([Closed Date]) - 30))"} >} [Record ID])


Or

Count({< [Closed Date] = {"$('>=' & Date(Max(TOTAL [Closed Date]) - 30))"} >} [Record ID])

Community Browser