# Exclude weekends(Saturdays and Sundays) from my dashboard view

**URL:** <https://discuss.elastic.co/t/exclude-weekends-saturdays-and-sundays-from-my-dashboard-view/272757>\
**Category:** Kibana\
**Created:** [May 12, 2021, 2:40am UTC](https://discuss.elastic.co/t/exclude-weekends-saturdays-and-sundays-from-my-dashboard-view/272757 "2021-05-12T02:40:38Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohanss08](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohanss08/32/82297_2.png) [@mohanss08](https://discuss.elastic.co/u/mohanss08)\
**Post date:** [May 12, 2021, 2:40am UTC](https://discuss.elastic.co/t/exclude-weekends-saturdays-and-sundays-from-my-dashboard-view/272757/1 "2021-05-12T02:40:38Z")

</div>

I am using ELK – 7.12.1 version and currently I am looking for a way to filter-out the weekends(Saturdays and Sundays) from my dashboard view.

On my Dashboard I have (Vertical Bar, Line, Data table, Pie & Gauge) chart visualizations. From all these I would want to filter out the weekends. Basically I want to exclude weekends from dashboard, So is it possible to do that?

If so please let me know the ways to achieve the same. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [May 12, 2021, 2:59am UTC](https://discuss.elastic.co/t/exclude-weekends-saturdays-and-sundays-from-my-dashboard-view/272757/2 "2021-05-12T02:59:15Z")

</div>

One way to achieve this is to create a scripted field.  
For example, the scripted field will return 1 for weekdays and 0 for weekends.  
Then filter the dashboard for documents that have 1 and not 0.  
Good luck!

---

<div class="post-metadata">

**Author:** ![mohanss08](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohanss08/32/82297_2.png) [@mohanss08](https://discuss.elastic.co/u/mohanss08)\
**Post date:** [May 12, 2021, 3:04am UTC](https://discuss.elastic.co/t/exclude-weekends-saturdays-and-sundays-from-my-dashboard-view/272757/3 "2021-05-12T03:04:24Z")

</div>

Ok Aclerk thanks for the pointer. the below is my scripted field.

```auto
Name: filter-weekend
Language: painless
Type: number
Format: Default
Popularity: 0
Script: doc['timestamp'].value.getDayOfWeekEnum()

**Preview Result:-**
[
 {
  "_id": "38009464",
  "filter-weekend": [
   "FRIDAY"
  ]
 },
 {
  "_id": "38026158",
  "filter-weekend": [
   "FRIDAY"
  ]
 },
 {
  "_id": "38030065",
  "filter-weekend": [
   "FRIDAY"
  ]
 },
 {
  "_id": "38035442",
  "filter-weekend": [
   "SATURDAY"
  ]
 },
 {
  "_id": "37688636",
  "filter-weekend": [
   "SATURDAY"
  ]
 },

With this still i can see the weekends(Saturday and Sunday).

```

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [May 12, 2021, 3:08am UTC](https://discuss.elastic.co/t/exclude-weekends-saturdays-and-sundays-from-my-dashboard-view/272757/4 "2021-05-12T03:08:00Z")

</div>

> [@mohanss08](#):
>
> `getDayOfWeekEnum`

I would use `int getDayOfWeek()` and not enum.  
Secondly, How did you get **Preview Result:-**? where is your filter?

---

<div class="post-metadata">

**Author:** ![mohanss08](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohanss08/32/82297_2.png) [@mohanss08](https://discuss.elastic.co/u/mohanss08)\
**Post date:** [May 12, 2021, 3:16am UTC](https://discuss.elastic.co/t/exclude-weekends-saturdays-and-sundays-from-my-dashboard-view/272757/5 "2021-05-12T03:16:25Z")

</div>

> doc['timestamp'].value.getDayOfWeek()

Preview result:-

```auto
[
 {
  "_id": "38009464",
  "filter-weekend": [
   5
  ]
 },
 {
  "_id": "38026158",
  "filter-weekend": [
   5
  ]
 },
 {
  "_id": "38030065",
  "filter-weekend": [
   5
  ]
 },
 {
  "_id": "38035442",
  "filter-weekend": [
   6
  ]
 },

```

With the above code it prints days in numbers but still i can see `6` Saturday. My preview result filter is `timestamp`.

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [May 12, 2021, 3:24am UTC](https://discuss.elastic.co/t/exclude-weekends-saturdays-and-sundays-from-my-dashboard-view/272757/7 "2021-05-12T03:24:08Z")

</div>

What did you run to get these results?  
This is what you should run, as to my understanding (need syntax validation)

```auto
GET /my-index/_search
{
  "query": {
    "bool": {
      "filter": [
        { "term": { "filter-weekend": "6" }},
        { "term": { "filter-weekend": "7" }}
      ]
    }
  }
}

```

or should be 1 & 7? please validate...

---

<div class="post-metadata">

**Author:** ![mohanss08](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohanss08/32/82297_2.png) [@mohanss08](https://discuss.elastic.co/u/mohanss08)\
**Post date:** [May 12, 2021, 3:34am UTC](https://discuss.elastic.co/t/exclude-weekends-saturdays-and-sundays-from-my-dashboard-view/272757/8 "2021-05-12T03:34:17Z")

</div>

`Kibna > Stack Management > Index Patterns > My-index > scripted fields` here after filling the fields i am checking in preview result section.

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [May 12, 2021, 3:37am UTC](https://discuss.elastic.co/t/exclude-weekends-saturdays-and-sundays-from-my-dashboard-view/272757/9 "2021-05-12T03:37:39Z")

</div>

Great.  
Now use this filed, as mentioned previously

> [@mohanss08](#):
>
> On my Dashboard I have (Vertical Bar, Line, Data table, Pie & Gauge) chart visualizations.

---

<div class="post-metadata">

**Author:** ![mohanss08](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohanss08/32/82297_2.png) [@mohanss08](https://discuss.elastic.co/u/mohanss08)\
**Post date:** [May 12, 2021, 3:47am UTC](https://discuss.elastic.co/t/exclude-weekends-saturdays-and-sundays-from-my-dashboard-view/272757/10 "2021-05-12T03:47:08Z")

</div>

> Vertical Bar  
> Y-axis  
> Aggregation: Count

> Buckets  
> X-axis  
> Aggregation: Filters  
> Filter-1: filter-weekend

This way i need to achieve this?

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [May 12, 2021, 3:51am UTC](https://discuss.elastic.co/t/exclude-weekends-saturdays-and-sundays-from-my-dashboard-view/272757/11 "2021-05-12T03:51:52Z")

</div>

I think you should use it in the search bar  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/f/2fc5da08215acac1af3ba69735f42e43d5b0aaef.png)

---

<div class="post-metadata">

**Author:** ![mohanss08](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohanss08/32/82297_2.png) [@mohanss08](https://discuss.elastic.co/u/mohanss08)\
**Post date:** [May 12, 2021, 4:31am UTC](https://discuss.elastic.co/t/exclude-weekends-saturdays-and-sundays-from-my-dashboard-view/272757/12 "2021-05-12T04:31:26Z")

</div>

Thank you so much Aclerk, i was trying to create a new visualization with newly created scripted field(filter-weekend), With your continues help and in my existing dashboard itself with the created scripted field able to create a filter in search bar and now weekends has been excluded. Thanks a lot once again.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 9, 2021, 4:31am UTC](https://discuss.elastic.co/t/exclude-weekends-saturdays-and-sundays-from-my-dashboard-view/272757/13 "2021-06-09T04:31:37Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
