Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Duration for a selected period

Good morning,

I have a field which indicates the number of rooms available in a hotel. For each record in the BBDD the numbers of rooms is repeated obviously. In order to know the number of rooms for any period I use =avg(inventory), so if one day the availables rooms were 528 it indicates so, and the same for one month, year..., 528.

Is correct that the inventory for one day is 528 rooms but if the selected period is, for example, 'jan' the correct inventory should be 528x31 if the period were year=2012 the correct inventory should be 528x366, etc.

I suppose exists a function to do something like vInventori=avg(inventori) x periodduration but I was not able to find it in any help or QV manual (as usual) I wonder if I am the only one that this happens.

Thanks

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hi,

Yes it does:

Day(MonthEnd(Fecha)) AS DiasMes

Will return the number of days in the month within the field Fecha

Hope that helps.

Miguel

View solution in original post

7 Replies
Not applicable
Author

Hi,

Based on your condition, you need to multiply the number of days based on the first day of your data up to selected month and year. Is this correct? Do you have a date field in your table?

Regards,

Janzen

Not applicable
Author

Hi,

yes I have a field with all the dates from n years ago to two moths forward in future, and a master calendar to treat them as individual month days (1,2,3...31), week days (mon,tue,...), individual months (jan, feb,...) , individual month-years (jan-2011, feb-2011) and so on.

I use the master calendar to filter the data in the document, I work basically with entire moths but when I refer to the current month I need consider from monthstart to today in order to calculate inventory.

Regards

Not applicable
Author

The way I intend to use the dates is something like this:

SELECTED HOTEL ROOMS = 528528
YEAR = 2012
INVENTORY
countrysJANFEBMARJANFEBMAR
CANADA528X31528X29528X31163681531216368
UK528X31528X29528X31163681531216368
FRANCE528X31528X29528X31163681531216368
AUSTRALIA528X31528X29528X31163681531216368
OCCUPPIED ROOMS
countrysJANFEBMAR
CANADA400025002700
UK200035005300
FRANCE600055001500
AUSTRALIA100020004200
%OCCUPPANCY
countrysJANFEBMAR
CANADA24%16%16%
UK12%23%32%
FRANCE37%36%9%
AUSTRALIA6%13%26%
TOTAL79%88%84%
Not applicable
Author

Hi,

Maybe you could try this one.

avg({<Year = {$(=only(Year))}, Month = {">min(date)<max(date)"} >} inventory)*Day(MonthEnd(date))

Regards,

Janzen

Not applicable
Author

Thank you, but It's too complicated for my kview knowledge.

I think I could solve my problem in the load sript simply adding a filed with the number of the month days ¿ is there any funtion which gives numbre of days for a month (JAN=31, FEB=28, MAR=31,...)?

My idea is doing something like

load

numberofdays(month(DATE)) as daysopen

from...

¿does it exist a funtion like numberofdays?

Thanks

Miguel_Angel_Baeyens

Hi,

Yes it does:

Day(MonthEnd(Fecha)) AS DiasMes

Will return the number of days in the month within the field Fecha

Hope that helps.

Miguel

Not applicable
Author

Thank you