2 Replies Latest reply on Feb 6, 2019 12:33 PM by Joe Oppelt

# Minimum Date of cumulative sums when a threshold is met

Hi,

I'm trying to find the minimum date where a threshold is met between two cumulative sums (calculated field in Tableau).

Let's say the data is structured a such:

DateAB
Cum_ACum_B
1/1/20191515
2/1/201910101115
3/1/2019401515
4/1/2019001515

If my threshold is 1, then when Cum_A - Cum_B <= 1, the minimum (first) date would be 3/1/2019.

I've tried doing another calculated field (Cum_A - Cum_B), but I have errors because of the aggregated field cannot be matched with a non-aggregated field while using if then statements.

How should I proceed?

Thanks!

• ###### 1. Re: Minimum Date of cumulative sums when a threshold is met

Hi Yan,

Do you have a sample workbook for this which you can upload?

Also I see that in the first row Cum_A - Cum_B = -4, so why would the minimum first date be 3/1/2019? Would you mind clarifying a bit further for my understanding.

Thanks,

Mavis

• ###### 2. Re: Minimum Date of cumulative sums when a threshold is met

I assume Cum_A and cum_B are running sums.  Create another calc that does Cum_B - Cum_A.

Then do WINDOW_MIN( IF [Cum Diff Calc] <= 1 then ATTR([Date]) END )

Run that last calc the same way you are running the CUM calcs (Probably TABLE(down), but whatever you are doing for those calcs would need to be the same for the MIN calc.)