Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
ydelreal
Partner - Contributor
Partner - 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
dplr-rn
Partner - Master III
Partner - Master III

Do you have a master calendar setup on Closed date?

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

ydelreal
Partner - Contributor
Partner - Contributor
Author

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

dplr-rn
Partner - Master III
Partner - Master III

Autogenerated one should have a month field too usually .

If not use the master calendar script from

Better Calendar Scripts | Qlikview Cookbook

ydelreal
Partner - Contributor
Partner - Contributor
Author

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

OmarBenSalem

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

dplr-rn
Partner - Master III
Partner - Master III

Something like below

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

or

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

dplr-rn
Partner - Master III
Partner - Master III

Any luck?

close the thread if it helped

ydelreal
Partner - Contributor
Partner - Contributor
Author

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])

Anil_Babu_Samineni

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])

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful