# How do I exclude weekends from the visuals?

**URL:** <https://community.amazonquick.com/t/how-do-i-exclude-weekends-from-the-visuals/30210>\
**Category:** Q&A\
**Tags:** error, calculations, Business-Intelligence-Engineer, quick-sight\
**Created:** [May 17, 2024, 7:54pm UTC](https://community.amazonquick.com/t/how-do-i-exclude-weekends-from-the-visuals/30210 "2024-05-17T19:54:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kris](https://avatars.discourse-cdn.com/v4/letter/k/82dd89/32.png) [@kris](https://community.amazonquick.com/u/kris)\
**Post date:** [May 17, 2024, 7:54pm UTC](https://community.amazonquick.com/t/how-do-i-exclude-weekends-from-the-visuals/30210/1 "2024-05-17T19:54:14Z")

</div>

How do I exclude weekends from the visuals? I have tried using conditional formula

isWorkday(date)

which gives me 1 for weekday and 0 for weekend, when I try to use it as a filter for a graph, exclude all 0s, or just include all 1s, it is showing an error.

sourceErrorCode:   
CONTEXTUAL\_INVALID\_ARGUMENT\_TYPE

How do I do this correctly?

---

<div class="post-metadata">

**Author:** ![Xclipse](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/xclipse/32/20455_2.png) [@Xclipse](https://community.amazonquick.com/u/Xclipse)\
**Post date:** [May 18, 2024, 6:09am UTC](https://community.amazonquick.com/t/how-do-i-exclude-weekends-from-the-visuals/30210/2 "2024-05-18T06:09:04Z")

</div>

Hi @kris, try this calculation:

1. **Create a Calculated Field** : Create a calculated field that determines whether a date is a weekday or a weekend. You can use a formula like this:

```auto
ifelse(
    extract('WD', {date_field}) IN [1, 2, 3, 4, 5], 1, 0
)

```

This formula extracts the day of the week from your date field, where 1 (Monday) to 5 (Friday) are considered weekdays and returns 1 for weekdays and 0 for weekends.

1. **Add the Calculated Field** : Add this calculated field to your dataset.
2. **Filter the Visual** : Now, you need to filter your visual to exclude weekends. Go to the analysis view where you have your visual, and apply a filter on the calculated field:

- Open the Filter pane.
- Click on `+ Add` and choose the calculated field you created.
- Set the filter to `Equals 1` to include only weekdays.

Also, here is another useful resource:

> [@Extracting a Textual Representation of a Day of the Week Extracted from a Date](https://community.amazonquick.com/t/extracting-a-textual-representation-of-a-day-of-the-week-extracted-from-a-date/17536):
>
> Dear Team, I am seeking guidance on the process of converting an existing dateTime value into a textual (string) representation that indicates the respective day of the week. for example “Aug 30, 2023” date will return just “Wednesday”. My initial approach involved using the extract('DD', {dateField}) function, but this method yields an integer result rather than the desired textual representation. To provide some context, my objective is to aggregate a specific field’s values over individua…

In case you need further assistance with your problem, please create a sample dashboard with sample dataset showing your problem state using Arena and please create a new post, so we can look at it from a fresh perspective. (Details on using Arena can be found here - [Quick Sight Arena](https://community.amazonquick.com/t/quicksight-arena-an-embedded-instance-of-quicksight-within-the-quicksight-community/21437)

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 Quick Sight Community!

---

<div class="post-metadata">

**Author:** ![kris](https://avatars.discourse-cdn.com/v4/letter/k/82dd89/32.png) [@kris](https://community.amazonquick.com/u/kris)\
**Post date:** [May 27, 2024, 12:27pm UTC](https://community.amazonquick.com/t/how-do-i-exclude-weekends-from-the-visuals/30210/4 "2024-05-27T12:27:47Z")

</div>

I have tried “extract” function and it worked. Thank you so much!

---

<div class="post-metadata">

**Author:** ![Xclipse](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/xclipse/32/20455_2.png) [@Xclipse](https://community.amazonquick.com/u/Xclipse)\
**Post date:** [May 29, 2024, 3:54am UTC](https://community.amazonquick.com/t/how-do-i-exclude-weekends-from-the-visuals/30210/5 "2024-05-29T03:54:04Z")

</div>

Archived on May 29, 2024, 3:54am UTC


