This is tip 10 of my Tableau Speed Tipping session. Refer to the Table of Contents to find the other tips.
Zoom axis using parameter
There’s an ongoing discussion in the data viz community on the big question: are we allowed to truncate axes? Well, the first thing you need to remember is to NEVER truncate axes on bar charts. NEVER. I’m not using this word lightly here. Just – don’t.
What about line charts, though? Well, there’s plenty of pro and con arguments, and maybe you don’t want to hash out that discussion with your end users. Instead, you want to give them a choice: zoom in on the values, or show the whole axis. And that’s done quite easily in Tableau.
Simply create a Boolean parameter called “Zoom axis?” or something to that effect. Create a calculated field (I’ll call it “zero line”) and use the following calculation:
IF [Zoom axis?] THEN NULL ELSE 0 END
Now drag this zero line field to detail, add a reference line for this field, and make the line invisible (Formatting, line: none). Edit your axis, keep the range on automatic, but deselect “Include zero”.
What does this do, exactly? When you select FALSE (or “No”) in your parameter, your calculated field will fill with the value 0 (zero). Since you added this field as a reference line, Tableau will start the axis at zero in order to display your (invisible) reference line. When selecting TRUE (or “Yes”) in the parameter, your calculation becomes null, meaning there’s no values in the reference line, and since Tableau will adapt the axis range automatically and you don’t force the program to include zero, the axis will zoom in on the values of your line.