4 Replies Latest reply on Jul 17, 2019 5:42 AM by Ken Flerlage

How could I specify Highest/lowest point on sparklines

Hi fans of Tableau:

I'm learning Tableau sparklines. I watched Andy's video How to Add Min/Max Indicators to Sparklines - YouTube and use superstores to practice. My column: year month(Order date), like Jan, 2015, my row: segment then sales. I created a calculation field : If [sales] = {fixed [segment]: min(sales)} then [sales] end. But I didn't get what I want. It showed a very small value for sales and not on the sparklines. Could anyone help me fix it? I tried different expressions but still didn't work.

• 1. Re: How could I specify Highest/lowest point on sparklines

Hi Du,

try to create calculation as min

IF      SUM([Sales]) = WINDOW_MIN(SUM([Sales])) THEN SUM([Sales])

END

Refer

thanks

sankar

1 of 1 people found this helpful
• 2. Re: How could I specify Highest/lowest point on sparklines

Try creating a calculated field like this:

Min or Max Sales

// Find a point for the min and max sales.

IF  SUM([Sales]) = MIN({FIXED [Segment]: MIN({FIXED [Segment], YEAR([Order Date]), MONTH([Order Date]): SUM([Sales])})}) OR

SUM([Sales]) = MAX({FIXED [Segment]: MAX({FIXED [Segment], YEAR([Order Date]), MONTH([Order Date]): SUM([Sales])})}) THEN

SUM([Sales])

END

Then plot that on your second axis.

Then make it a dual axis:

And synchronize the axes:

Then change the mark type on the second axis to "Circle" and manually adjust the size as desired:

If you'd like to color the dots differently based on whether they are min or max, then create another calculated field:

Is Min or Max

// Find a point for the min and max sales.

IF  SUM([Sales]) = MIN({FIXED [Segment]: MIN({FIXED [Segment], YEAR([Order Date]), MONTH([Order Date]): SUM([Sales])})}) THEN

"Min"

ELSEIF SUM([Sales]) = MAX({FIXED [Segment]: MAX({FIXED [Segment], YEAR([Order Date]), MONTH([Order Date]): SUM([Sales])})}) THEN

"Max"

END

Then drop that on the color card on the second axis and adjust your color palette.

See attached.

1 of 1 people found this helpful
• 3. Re: How could I specify Highest/lowest point on sparklines

Thanks for your detailed explaination and instruction!! I did try to use fixed like that but I only tried fixed segment and month(order date)

Could you explain why did you use min() twice?

I think {FIXED [Segment]: MIN({FIXED [Segment], YEAR([Order Date]), MONTH([Order Date]): SUM([Sales])})} has already generate only one value for segment.

• 4. Re: How could I specify Highest/lowest point on sparklines

You're correct. That will generate the correct value, but we need to compare it to SUM(Sales). Since SUM(Sales) is an aggregate, we need the above to be an aggregate too. So I used MIN. Technically, we could've used AVG, or MAX or even ATTR.