简体   繁体   中英

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

资料范例

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

Select Add to Context on your relative range date filter.

在此处输入图片说明

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:

在此处输入图片说明

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])

在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM