Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Days in selected months

Hello helpers...

I have a month selector from which many can be selected and a year selector from which only one can be picked.

For any given selection of year and month(s), I'd like to have the number of days for that selection. So I might select February, July and October 2012 and therefore want the number of days to be 29 + 31 + 31 = 91 days. This isn't a standard date diff as I don't want the period between selections.

Any help will be much appreciated

Cheers,

Geoff.

1 Solution

Accepted Solutions
Gysbert_Wassenaar

You should probably just fix this in the script by adding a table with the numbers of days per month. If you have a date field too you could simply do a count of the date field.

If all you have is a Year and Month field you can try:

=ceil($(=concat(Monthend(MakeDate(Year,aggr(Month,Month),1))-Monthstart(MakeDate(Year,aggr(Month,Month),1)) ,'+')))


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar

You should probably just fix this in the script by adding a table with the numbers of days per month. If you have a date field too you could simply do a count of the date field.

If all you have is a Year and Month field you can try:

=ceil($(=concat(Monthend(MakeDate(Year,aggr(Month,Month),1))-Monthstart(MakeDate(Year,aggr(Month,Month),1)) ,'+')))


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks for the reply Gysbert. I've created a table of 'days in months' for all the months and years I need which is independent of my dataset and joined it in the set analysis.

=sum({<Days.monthName = {"$(vSelectedMonths)"}, Days.yearNumber={'$(=Only(Year))'}>} Days.numDays)

Top man!

Cheers.