8 Replies Latest reply on Nov 14, 2017 11:07 AM by Tyler McDonald

# How do I keep track of how many consecutive false values have occurred in the past months? Tableau 10.2.0

Hi all,

In Tableau, I have a list of months that are each related to a separate value. Example:

MonthBoolean
JanuaryTrue
FebruaryTrue
MarchFalse
AprilTrue
MayFalse
JuneFalse

I would like to create a calculated field that gets how many consecutive falses have occurred in the current and past months. Example:

MonthBooleanCount
JanuaryTrue0
FebruaryTrue0
MarchFalse1
AprilTrue0
MayFalse1
JuneFalse2

I was trying to use something like the LOOKUP function, but I couldn't figure it out. Any help would be greatly appreciated! Thanks!

• ###### 1. Re: How do I keep track of how many consecutive false values have occurred in the past months? Tableau 10.2.0

You want to use the PREVIOUS_VALUE() function.  That lets you look at what was in the previous cell, and do things based on the value.  (You can also use LOOKUP([whatever]. -1). )

Posting a sample workbook would really help out here if you can't make it work.  it's a whole lot easier to show you than to explain it.

• ###### 2. Re: How do I keep track of how many consecutive false values have occurred in the past months? Tableau 10.2.0

So, in my example, would I want to create a Calculated Field like:

IF PREVIOUS_VALUE([Boolean]) = False

THEN 1

ELSEIF PREVIOUS_VALUE([Boolean]) = True

THEN 0

END

I tried that on my Tableau, but it gives me an error.

• ###### 3. Re: How do I keep track of how many consecutive false values have occurred in the past months? Tableau 10.2.0

I'll repeat:

Posting a sample workbook would really help out here if you can't make it work.  it's a whole lot easier to show you than to explain it.

I want to try out what I suggest to make sure what I say is correct.

• ###### 4. Re: How do I keep track of how many consecutive false values have occurred in the past months? Tableau 10.2.0

Sorry. Before I do, I just need to ask a few quick questions about it. When you say workbook, do you mean the Tableau worksheet with export, or the excel workbook? Also, the test data I am working with currently is pretty much an excel spreadsheet with the same data listed in the example tables I gave in my question. In other words, I'm working with completely general data before specializing it for production. Is that okay for when I upload it?

• ###### 5. Re: How do I keep track of how many consecutive false values have occurred in the past months? Tableau 10.2.0

The workbook itself (which maybe will have just one sheet).

And sample data is perfect.  We don't need to have proprietary data posted on the internet.  If your workbook is based on an excel sheet, the Export Packaged Workbook (which creates a TWBX file) will contain your data without the need to export the data.

• ###### 6. Re: How do I keep track of how many consecutive false values have occurred in the past months? Tableau 10.2.0

So pretty much, I want to count the number of consecutive "Missed" values and then the counter resets when it reaches a "Met".

• ###### 7. Re: How do I keep track of how many consecutive false values have occurred in the past months? Tableau 10.2.0

See attached.

1 of 1 people found this helpful
• ###### 8. Re: How do I keep track of how many consecutive false values have occurred in the past months? Tableau 10.2.0

Thank you so much! This looks perfect.