Qlik Community

Qlik Sense Deployment & Management

Discussion board where members learn more about Qlik Sense Installation, Deployment and Management.

zied_ahmed1
Contributor III

count number days in selected months

Hello everybody,

i want to count number days in selected months i use this but it gives me 31 for all Months :

CEIL(NUM(MonthEnd(Max([Month of date])) - MonthStart(MIN([Month of date]))))

1 Solution

Accepted Solutions
rahulpawarb
Valued Contributor III

Re: count number days in selected months

Hello Zied,

Below given expression will fetch the desired results:

=Day(MonthEnd(Date(Date#(GetFieldSelections(Month), 'MMM'))))

NOTE: If Month present in your data model is derived from Date Field then you can opt for earlier given expression. If it is not then aforementioned expression will consider month from year 1899. This will give you 28 as result for February though you are analyzing a leap year.

Regards!

Rahul

9 Replies
laddu_927
Valued Contributor

Re: count number days in selected months

What value is stored in Month of date??

zied_ahmed1
Contributor III

Re: count number days in selected months

name of Month

rahulpawarb
Valued Contributor III

Re: count number days in selected months

Hi Zied,

If you have date field in your data model then use below expression to get the days in selected month:

=Day(MonthEnd(MaxString(Date)))

Hope this will be of help.

Thank you!

Rahul

zied_ahmed1
Contributor III

Re: count number days in selected months

Hello Rahul,it doesn't work and this is my Month of date :

Month.PNG

Regards

zied_ahmed1
Contributor III

Re: count number days in selected months

I need when i select Janv the result is 31,February 28,March 31 April 30 ....

rahulpawarb
Valued Contributor III

Re: count number days in selected months

Hello Zied,

Would it be possible to share the application?

Regards!

Rahul

rahulpawarb
Valued Contributor III

Re: count number days in selected months

Hello Zied,

Below given expression will fetch the desired results:

=Day(MonthEnd(Date(Date#(GetFieldSelections(Month), 'MMM'))))

NOTE: If Month present in your data model is derived from Date Field then you can opt for earlier given expression. If it is not then aforementioned expression will consider month from year 1899. This will give you 28 as result for February though you are analyzing a leap year.

Regards!

Rahul

zied_ahmed1
Contributor III

Re: count number days in selected months

Hello Rahul this is the solution thank you

rahulpawarb
Valued Contributor III

Re: count number days in selected months

Cheers,

Rahul

Community Browser