Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
zied_ahmed1
Specialist
Specialist

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
Specialist III
Specialist III

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

View solution in original post

9 Replies
Anonymous
Not applicable

What value is stored in Month of date??

zied_ahmed1
Specialist
Specialist
Author

name of Month

rahulpawarb
Specialist III
Specialist III

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
Specialist
Specialist
Author

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

Month.PNG

Regards

zied_ahmed1
Specialist
Specialist
Author

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

rahulpawarb
Specialist III
Specialist III

Hello Zied,

Would it be possible to share the application?

Regards!

Rahul

rahulpawarb
Specialist III
Specialist III

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
Specialist
Specialist
Author

Hello Rahul this is the solution thank you

rahulpawarb
Specialist III
Specialist III

Cheers,

Rahul