Hi @Michelle, welcome to the QuickSight Community. Letâs dive into the process of calculating the number of vacation days, ensuring that it meets the rule of having 6 consecutive days excluding weekends.
Step-by-Step Process in Amazon QuickSight
Step 1: Data Preparation
Before proceeding, ensure your dataset includes all necessary columns, particularly the vacation departure and return dates, along with employee IDs.
Step 2: Creating Calculated Fields
- Create a Date Column: Ensure you have a date column covering all possible dates. If not, you might need to generate it in your data preparation step before importing it into QuickSight.
- Create Calculated Fields for Day of Week and Is Weekday:
Pseudocode (Syntax may vary)
extract("WD", {Vacation departure})
This function extracts the day of the week from the vacation departure date, where Monday = 1 and Sunday = 7.
Pseudocode (Syntax may vary)
ifelse(extract("WD", {Vacation departure}) IN [1, 7], 'Weekend', 'Weekday')
- Running Total of Vacation Days: To track consecutive days, use the
sumOver
function:
Pseudocode (Syntax may vary)
sumOver(ifelse({Is Weekday} = 'Weekday', 1, 0), [{Employee ID}], PRE_AGG)
- Count Consecutive Vacation Days: Use the
runningSum
function to count consecutive weekdays:
Pseudocode (Syntax may vary)
runningSum(ifelse({Is Weekday} = 'Weekday' AND not isNull({Employee ID}), 1, 0), [{Employee ID}], [{Vacation departure}], ASC)
- Check for 6 Consecutive Days: Create a calculated field to check if there are 6 consecutive weekdays:
Pseudocode (Syntax may vary)
ifelse({Running Total} >= 6, 1, 0)
Step 3: Filtering and Aggregating Data
- Filter Out Weekends: Apply a filter to exclude weekends from your analysis in QuickSight:
- Use the filter pane to add a filter on
Is Weekday
and select Weekday
.
- Visualization:
- Use a pivot table or summary table to aggregate the data by employee ID and date, showing the count of consecutive days.
Example Steps in QuickSight
- Create the Dataset: Ensure your dataset includes
Employee ID
, Vacation departure
, and Vacation return
fields.
- Create Calculated Fields:
- Navigate to
Analysis
.
- Click on
Add
â Calculated Field
.
- Add the calculated fields as discussed above.
- Apply Filters:
- In the analysis pane, add a filter for
Is Weekday
.
- Exclude weekends by selecting
Weekday
.
- Build the Visualization:
- Use a table or pivot table visualization.
- Add
Employee ID
, Vacation departure
, and your calculated fields to the visualization.
Example Calculations:
- Day of Week Calculation:
Pseudocode (Syntax may vary)
extract("WD", {Vacation departure})
- Is Weekday Calculation:
Pseudocode (Syntax may vary)
ifelse(extract("WD", {Vacation departure}) IN [1, 7], 'Weekend', 'Weekday')
- Running Total of Vacation Days:
Pseudocode (Syntax may vary)
sumOver(ifelse({Is Weekday} = 'Weekday', 1, 0), [{Employee ID}], PRE_AGG)
- Count Consecutive Vacation Days:
Pseudocode (Syntax may vary)
runningSum(ifelse({Is Weekday} = 'Weekday' AND not isNull({Employee ID}), 1, 0), [{Employee ID}], [{Vacation departure}], ASC)
- Check for 6 Consecutive Days:
Pseudocode (Syntax may vary)
ifelse({Running Total} >= 6, 1, 0)
Visualization Example:
Create a table visualization showing:
Employee ID
Vacation departure
Vacation return
Running Total
Consecutive Days
This should help you visualize and ensure the vacation days meet the criteria of 6 consecutive days excluding weekends.
Did this solution work for you? I am marking this reply as, âSolution,â but let us know if this is not resolved. Thanks for posting your questions on the QuickSight Community!
In case you need further assistance with your problem, please create a sample dashboard with sample dataset showing your problem state using Arena and post it here. (Details on using Arena can be found here - QuickSight Arena