L.Rencoret
L.Rencoret

Reputation: 155

Tableau - Divide values from 2 dates

I need help making a division with a relative date range.

For example: Date Range: 01-01-2015 & 20-01-2015 Divison: 1.209,812 / 1.207,810 = 1,0016575

Example of Data

Upvotes: 0

Views: 430

Answers (1)

Bernardo
Bernardo

Reputation: 3318

You can do this with a combination of LOD calcs and a Context Filter.

Select Add to Context on your relative range date filter.

enter image description here

Create Level of Detail calcs to isolate the min and max dates based on your filter

{max([Order Date])}

and

{min([Order Date])}

Create min and max values based on your measures. I'm using the Superstore data set in this example. The calculation states if the date equals the max date, return the Sales value. Repeat for min values.

if [Order Date] = [max date] then [Sales] end

You should have something like this:

enter image description here

Now just create a division between the max and min. You'll need to remove the date from the view for the calculation to render.

sum([max value]) / sum([min value])

enter image description here

See attached sample workbook if needed. https://www.dropbox.com/s/1ed15pwhihmjkdv/181227%20stack%20question.twbx?dl=0

Upvotes: 1

Related Questions