
1. Re: Line Color Based on Increasing or Decreasing trend
Ben Neville Aug 2, 2017 10:29 AM (in response to Abdul Subhan Mohammed)Try something like this:
IF WINDOW_MAX(IF SIZE() = INDEX() THEN SUM([Sales]) END) >= WINDOW_MAX(IF SIZE()1 = INDEX() THEN SUM([Sales]) END)
THEN "Higher"
ELSE "Lower"
END
Place that calculation on color, and assign red and green as appropriate. The output can be a number or whatever text you want  I just picked higher and lower. The trick is to get a value that returns the same for the whole line, so we need a table calculation (though an LoD would work, although it's more complex). The above calculation uses WINDOW_MAX to find the maximum values in the whole sheet. The only values that are ever thrown are those in the last 2 datapointts  the rest will be null, so the max will always pull only the 2 we want.

2. Re: Line Color Based on Increasing or Decreasing trend
Jim Dehner Aug 2, 2017 10:54 AM (in response to Abdul Subhan Mohammed)Hi
I did this in 2 parts  first to determine the direction of the last segment of the line
if LOOKUP(sum([Sales]),last())  lookup(sum([Sales]),(last()1)) <0 then 1 else 2 end
Then to color the line in total
if [color line last segment]= 1 then "Red" elseif
[color line last segment]=2 then "Green" end
Then place the color of the last segment on detail and the color total line on color and you will get this
Or
Let me know if this is what you expected
Jim
If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution. Thank you.

Trend coloring.twbx 6.7 MB


3. Re: Line Color Based on Increasing or Decreasing trend
Abdul Subhan Mohammed Aug 2, 2017 4:57 PM (in response to Jim Dehner)Thank You so much Jim,
I was able to get it working also with your approach but a single query is better than 2 and since we had one, I chose it as the correct answer. Yours is Correct as well !
Thank You so much for responding. I really appreciate your helping me out here.
Regards,
Abdul

4. Re: Line Color Based on Increasing or Decreasing trend
Abdul Subhan Mohammed Aug 2, 2017 4:58 PM (in response to Ben Neville)Thank You so much Ben !
It worked!
Abdul