Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
shaan007
Partner - Creator
Partner - Creator

find total days in a month from a date selection

Hi ,

This is a simple question on SET analysis,

I am looking for an efficient method to find total days in a month from a date selection.

When user select a date,  example PK_CALENDAR -> 6/7/2015 , the result is 31.

I have a master calendar has PK_CALENDAR, Month, Year

Solution 1:  this one have problem if a selection date is xx/02/2015  or xx/02/2016- result 29

=(
MaxString({1<Month ={'$(=month(PK_CALENDAR))'}>}Day)//Day is month days

)

Solution2:  Works perfect!

=(
Count({1<
Year = {'$(=Year(PK_CALENDAR))'}
,
Month ={'$(=Month(PK_CALENDAR))'}
>}
DISTINCT PK_CALENDAR
)
)

Is there any other better solution?

1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi,

  this can be achieved without set analysis.

         

    =Floor(MonthEnd(CurrentDate)) - Floor(MonthStart(CurrentDate)) + 1

View solution in original post

4 Replies
Anonymous
Not applicable

Hi,

  this can be achieved without set analysis.

         

    =Floor(MonthEnd(CurrentDate)) - Floor(MonthStart(CurrentDate)) + 1

tresesco
MVP
MVP

Day(MonthEnd(Max(Date)))

shaan007
Partner - Creator
Partner - Creator
Author

Thank you

sasiparupudi1
Master III
Master III

=floor(MonthEnd(PK_CALENDAR)-MonthStart(PK_CALENDAR))