How to highlight first negative number inn Table in Tableau?

21 Views Asked by At

Table contains date and ice-cream sales. Based on Ice cream field highlight the 1st negative number.

I am creating a calculation field using the Index function. Indexing func: IF SUM([Sales]) < 0 THEN INDEX() END

And I am comparing it with the actual index function [![enter image description here][1]][1]below.

Index() = Indexing func I dragged this comparison calc field to color, whenever it matches it should highlight the 1st negative number.

But it is highlighting all the negative numbers in the field.

enter image description here

1

There are 1 best solutions below

0
Alex Blakemore On

Here is a simple solution that works when you are not using Date as dimension on your view. Otherwise, you can definitely use table calcs - which work but are a bit trickier.

Create a calculated field that holds the Date if it meet s your selection criteria (negative sales in this case) and will be null otherwise. Call the field something like Date_With_Negative_Sales

if [Sales] < 0 then [Date] end

Then you can use Date_With_Negative_Sales on the view as a measure, with either MIN() or MAX() to show the first date or last date with negative sales.