Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Customer & Partners, DEC. 9, 11 AM ET: Qlik Product & Strategy Roadmap Session: Data Analytics REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
rohitraturi
Contributor II
Contributor II

Calculating number of days

I want to calculate the number of days for three months (current month and previous two months) when I select the current month.

Example: If I select Dec then I should get days from Dec, Nov, and Oct i.e. 92 days.

I am using the following code but it works only when I select Oct and Dec.

Floor(MonthEnd(Max([Posting Date])))- Floor(MonthStart(Min([Posting Date])))+ 1

2 Replies
seanbruton
Luminary Alumni
Luminary Alumni

Hi There,

 

I have a similar code running which is below, the trick is to do the calculation and bracket it then add the 1 day afterward.

 

(
Floor(MonthEnd(Max(if(CYTD_Ind = 1,[CalcDate]))))
-
AddMonths(monthstart(min(Floor(if(CYTD_Ind = 1,[CalcDate])))),1)
)+1

 

in your case:

(
Floor(MonthEnd(Max([Posting Date])))
-
AddMonths(monthstart(min(Floor([Posting Date]))),1)
)+1

 

Regards, Good Luck!

 

 

Anil_Babu_Samineni

Perhaps this?

Count({<DateField = {">=$(=Date(MonthStart(AddMonths(Max(Month), -3)),'Your Date Format Here'))<=$(=Date(MonthEnd(Max(Month)),'Your Date Format Here'))"}>} DateField)

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)