Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
format table cell based on value in another cell in the same table
cbowman
<p>Sorry is this is a re-post. I looked but couldn't find anything quite like this.</p><p> </p><p>I want to change the formatting of a cell based on if it is below a certain value. The issue is that the value that I want to compare it to is in the same table. How do I compare specific cell values in a table?</p>
Find more posts tagged with
Comments
lnix
<p>You could do this with a Highlight rule on your data element.</p>
cbowman
<p>It seems like highlight rules compare cell values to fixed values. At least that is how the examples that I've seen are. (I am new at this).</p><p> </p><p>For example </p><p>time period sales</p><p>yesterday $23,452</p><p>today $22,856</p><p> </p><p>if today's sales exceed yesterday, I want to change the formatting. </p>
lnix
<p>You can set the target value of a highlight rule to another column in the table. You just click the function button next to the field. I've uploaded a screen shot of the function button and a sample report.</p>
cbowman
<p>Thanks Lindsay but I am either not understanding or not making my point clear - probably both. Here is a little more complicated table:</p><p> </p><div>time period<span> </span> sales</div><div>last month<span> </span> $444,700</div><div>last week<span> </span> $111,825.0 </div><div>yesterday<span> </span> $23,452 </div><div>today<span> </span> $22,856 </div><div>goal<span> </span> $21,000 </div><div> </div><div>So, I want to change the formatting sales today ('$22.856') when those sales exceed the sales yesterday. I don't want to change any other formatting just the one cell representing today sales.</div><div> </div><div>Your example highlighted multiple cells in the column. </div>
kclark
<p>First create a PGV in the initialize() of the report</p><pre class="_prettyXprint">reportContext.setPersistentGlobalVariable("salesNumber", "0")</pre><p>In the onCreate() of Time Period you need to set it as a PGV.
</p><pre class="_prettyXprint">reportContext.setPersistentGlobalVariable("timePeriod", this.getValue())</pre><p>Then in the onCreate() of sales use this script. It will check the last value and the current time period. If time period is TODAY and the number is less than Yesterday then it changes the cell background to red.</p><pre class="_prettyXprint">var salesNumber = reportContext.getPersistentGlobalVariable("salesNumber");var timePeriod = reportContext.getPersistentGlobalVariable("timePeriod");if(this.getValue() < salesNumber && timePeriod == "Today") { this.getStyle().backgroundColor = "red";}reportContext.setPersistentGlobalVariable("salesNumber", this.getValue())</pre>
cbowman
<p>Brilliant - Thanks</p><p>It works great.</p>