Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculating Weekend vs. NonWeekend Stay

I'm trying to calculate the number of air itineraries where an air traveler has a weekend stay included and when an air traveler does not have a weekend stay included.  The data I have is the following:

Air intinerary (Field: air_itin)

Air travel date (Field: air_travel_date)

No. of days traveling (Field: itin_trip_days)

Day of week with 1=Sun and 7 = Saturday (Field: DayofWeek.Weekday)

Is there a way to do the following:

1.  Calcuate the full date range of trip by using: (air_itin) to (air_itin + itin_trip_days)

2. Apply the Day of Week to this date range

3. Flag as Weekend stay if range includes a 6 or 7

Any help is greatly appreciated.

3 Replies
danielrozental
Master II
Master II

how about something like this

    

     if(weekday(air_travel_date)+1+itin_trip_days>=6,1,0) AS HAS_WEEKEND

Not applicable
Author

Hi Daniel,

Thank you for the input.  If I was to link to the each air itinerary in the data set, would I have to run this in my script as a partial reload?  Is there any special syntax I need to use aside from the if function if so?

Otherwise, I'm happy to just calculate the number of hotel itineraries that have a weekend stay, but in trying to input the formula am getting an error in the expression.  This is what I have as the formula currently:

Count(

if((weekday([air_travel_dt])+1+[itin_trip_days])>5),

[HOTEL.hot_itin])

If there is a manual or resource with examples for different types of functions, I'd love to download a copy!

Thanks again,

Kelly

danielrozental
Master II
Master II

I think you have a couple misplaced ")"

Count(
if((weekday([air_travel_dt])+1+[itin_trip_days]>5,
[HOTEL.hot_itin]))

No, this doesn't need to be included in the load, you could do this as an expression in a chart. Although it might be preferable performance wise.