
1. Re: Plotting a line in Tableau
swaroop.gantela May 1, 2018 7:19 PM (in response to Andrew Lemon)Andrew,
Here's one method that might give an idea.
If there are set breakpoints, you could write an equation for each section:
In the workbook attached in the Forum thread,
I plotted Log (Sales) vs. Discount and line breakpoints were
1  0, 10  10%, 100  25%, 1000  30%, 10000  60%
So the calculated field first picks out the range,
calculates the line slope, multiplies the xoffset log(sales), adds a yoffset:
IF [Sales]>1 AND [Sales]<10 THEN LOG(Sales)*0.1
ELSEIF [Sales]>10 AND [Sales]<100 THEN ((0.250.1)/(LOG(100)LOG(10)))*(LOG([Sales])LOG(10))+0.1
ELSEIF [Sales]>100 AND [Sales]<1000 THEN ((0.30.25)/(LOG(1000)LOG(100)))*(LOG([Sales])LOG(100))+0.25
ELSEIF [Sales]>1000 AND [Sales]<10000 THEN ((0.60.3)/(LOG(10000)LOG(1000)))*(LOG([Sales])LOG(1000))+0.3
END
The color flag is then just
[Discount]>[DiscountLine]

269082disc.twbx 1.2 MB


2. Re: Plotting a line in Tableau
Andrew Lemon May 2, 2018 9:01 PM (in response to swaroop.gantela)This was absolutely amazing!
Thank you!!!!