2 Replies Latest reply on Apr 18, 2016 11:46 PM by Michał Wrobel

# How countD dimension elements in date range

Hi,

I have Date and dimension.

For each Day I need to countD dimension element in last 5 days.

For example for 12.01 i need to countD element from 7.01 to 12.01 = 3

For example for 13.01 i need to countD element from 8.01 to 13.01 = 3

For example for 5.01 i need to countD element from 1.01 to 5.01 = 5

How to calculate this in tableau ?

Is it possible ?

Regards Michał

• ###### 1. Re: How countD dimension elements in date range

Create a Date Parameter : [Select Date]

Calculation : Last 5 Days ?:

[Date] >= { FIXED : MAX([Select Date])} - 5

AND

[Date] <= { FIXED : MAX([Select Date])}

Drag [Last 5 Days ?] to filter and select true.

Drag Dimension to column and set it to Count Distinct.

Use parameter to select days.

Attached workbook.

-Nirupam

• ###### 2. Re: How countD dimension elements in date range

Hi,

With parameter is simple.

But I need this for all date - all rows.

For example I have table with date :

2016-04-10

2016-04-11

2016-04-12

2016-04-13

2016-04-14

I need have time window 5 days for all every record :

2016-04-10 - from 2016-04-05

2016-04-11 - from 2016-04-06

2016-04-12 - from 2016-04-07

2016-04-13 - from 2016-04-08

2016-04-14 - from 2016-04-09

Is possible to do in tableau ?