8 Replies Latest reply on Nov 3, 2015 1:34 PM by Peter Harris

# Total Number of Boolean Transitions

Hi

I have a data set with a field that has a Boolean value of T/F and would like to count the number of transitions between the two states. For eg. T T F T T would have 2 transitions while T T F F F would only have one.

Any pointers to the correct function would be appreciated.

Thanks for looking

Pete

• ###### 1. Re: Total Number of Boolean Transitions

Peter, attach a sample workbook or dataset if you want an exact and quick answer.

Here is my idea of counting them.

1.Convert t/f into numbers

if 'T' then 1

else 0

end

2.Use the Quick Table calculations to calculate the difference from previous vlaue.

3.Sum up the absolute values: Sum(ABS(Difference))

This gives you the number of transitions.

• ###### 2. Re: Total Number of Boolean Transitions

Thanks Alexander this is helpful

I have attached a workbook with some simplified data. The field Panel.Growth is the parameter that i am looking at. I would like to calculate the number of times that this field changes from T to F for each antibiotic with a simple calculated field so that i can use the calculated value in some other calculations later. Any ideas would be appreciated.

Thanks

• ###### 4. Re: Total Number of Boolean Transitions

Thanks again Alexander this was very helpful

Pete

• ###### 5. Re: Total Number of Boolean Transitions

Sounds like this is not exactly what u expected .

On Tuesday, November 3, 2015, Peter Harris <

• ###### 6. Re: Total Number of Boolean Transitions

Alex

Firstly, I appreciate the work that you have put in to this and your method definitely yields the correct number for total transitions between the two states. This is further than I was able to get and your code is more elegant than my solution. The problem that I am facing is that I need to use the calculated number as a variable in further calculations and this does not seem possible with the results of table calculations. The count of T/F transitions was an idea as to how we might achieve a more complicated filter, I may have to come up with another method.

• ###### 7. Re: Total Number of Boolean Transitions

You got what you asked for.

Anything is possible with tableau.

On Tuesday, November 3, 2015, Peter Harris <

• ###### 8. Re: Total Number of Boolean Transitions

You are correct…sometimes as a newbie to scripting in Tableau part of the issue is learning what question to ask

Thanks for your help