<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Alternating Color Based on Alternating Data</title>
	<link>http://sixfriedrice.com/wp/alternating-colors/</link>
	<description>smart business solutions</description>
	<pubDate>Thu, 04 Dec 2008 21:25:32 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
		<item>
		<title>By: Geoff Coffey</title>
		<link>http://sixfriedrice.com/wp/alternating-colors/#comment-1222</link>
		<dc:creator>Geoff Coffey</dc:creator>
		<pubDate>Thu, 19 Jun 2008 21:29:50 +0000</pubDate>
		<guid>http://sixfriedrice.com/wp/alternating-colors/#comment-1222</guid>
		<description>@dick:

That will work well if you're certain every sequential day will be represented in the list. But it breaks down if you have gaps. For instance, suppose you have 3 records on January 3rd, none for the 4th, and then a few more for the 5th. In that case, the two sets would be side-by-side and of the same color.

Geoff</description>
		<content:encoded><![CDATA[<p>@dick:</p>
<p>That will work well if you&#8217;re certain every sequential day will be represented in the list. But it breaks down if you have gaps. For instance, suppose you have 3 records on January 3rd, none for the 4th, and then a few more for the 5th. In that case, the two sets would be side-by-side and of the same color.</p>
<p>Geoff</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dick</title>
		<link>http://sixfriedrice.com/wp/alternating-colors/#comment-1218</link>
		<dc:creator>Dick</dc:creator>
		<pubDate>Mon, 16 Jun 2008 05:48:50 +0000</pubDate>
		<guid>http://sixfriedrice.com/wp/alternating-colors/#comment-1218</guid>
		<description>err.. with an additional proviso for months ending odd</description>
		<content:encoded><![CDATA[<p>err.. with an additional proviso for months ending odd</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dick</title>
		<link>http://sixfriedrice.com/wp/alternating-colors/#comment-1217</link>
		<dc:creator>Dick</dc:creator>
		<pubDate>Mon, 16 Jun 2008 05:46:15 +0000</pubDate>
		<guid>http://sixfriedrice.com/wp/alternating-colors/#comment-1217</guid>
		<description>For 2 colours why not just do a calc on odd or even day numbers
and go straight to Conditional formatting from there.</description>
		<content:encoded><![CDATA[<p>For 2 colours why not just do a calc on odd or even day numbers<br />
and go straight to Conditional formatting from there.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geoff Coffey</title>
		<link>http://sixfriedrice.com/wp/alternating-colors/#comment-1205</link>
		<dc:creator>Geoff Coffey</dc:creator>
		<pubDate>Sat, 07 Jun 2008 00:55:11 +0000</pubDate>
		<guid>http://sixfriedrice.com/wp/alternating-colors/#comment-1205</guid>
		<description>@david:

Yes, if the data isn't sorted it "works" in that contiguous ranges are still colored properly, but it doesn't do what you describe. If you want that behavior, you might consider using a conditional formatting approach based on the date itself. For instance, imagine these 5 conditional formatting rules:

&lt;pre&gt;&lt;code&gt;Mod(GetAsNumber(DATE_FIELD), 5) = 0
Mod(GetAsNumber(DATE_FIELD), 5) = 1
Mod(GetAsNumber(DATE_FIELD), 5) = 2
Mod(GetAsNumber(DATE_FIELD), 5) = 3
Mod(GetAsNumber(DATE_FIELD), 5) = 4&lt;/code&gt;&lt;/pre&gt;

This would have the problem that two side-by-side dates that are an even multiple of 5 days apart would be the same color, which might be problematic. But I'm not sure how possible it would be to fix that problem and still keep same-color-for-same-date behavior.

You could also color code based on the number of days in the past, which might be cool. One color for 0 to 3 days, another for 4 to 10, etc... Something like that.

Anyway, thanks to Todd for inspiring this. It is a very cool idea to color code rows based on data similarities.

Geoff</description>
		<content:encoded><![CDATA[<p>@david:</p>
<p>Yes, if the data isn&#8217;t sorted it &#8220;works&#8221; in that contiguous ranges are still colored properly, but it doesn&#8217;t do what you describe. If you want that behavior, you might consider using a conditional formatting approach based on the date itself. For instance, imagine these 5 conditional formatting rules:</p>
<pre><code>Mod(GetAsNumber(DATE_FIELD), 5) = 0
Mod(GetAsNumber(DATE_FIELD), 5) = 1
Mod(GetAsNumber(DATE_FIELD), 5) = 2
Mod(GetAsNumber(DATE_FIELD), 5) = 3
Mod(GetAsNumber(DATE_FIELD), 5) = 4</code></pre>
<p>This would have the problem that two side-by-side dates that are an even multiple of 5 days apart would be the same color, which might be problematic. But I&#8217;m not sure how possible it would be to fix that problem and still keep same-color-for-same-date behavior.</p>
<p>You could also color code based on the number of days in the past, which might be cool. One color for 0 to 3 days, another for 4 to 10, etc&#8230; Something like that.</p>
<p>Anyway, thanks to Todd for inspiring this. It is a very cool idea to color code rows based on data similarities.</p>
<p>Geoff</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Zakary</title>
		<link>http://sixfriedrice.com/wp/alternating-colors/#comment-1200</link>
		<dc:creator>David Zakary</dc:creator>
		<pubDate>Fri, 06 Jun 2008 21:30:04 +0000</pubDate>
		<guid>http://sixfriedrice.com/wp/alternating-colors/#comment-1200</guid>
		<description>That works better. Works perfectly if the data is sorted by the Date field. Works ok if unsorted. 

Ideally (this is based on what my client wanted) is that if there were duplicated, but non-contiguous, dates they would show up the same colour. In this version they take on the next value in the custom formatting series.

Thanks for your work on this</description>
		<content:encoded><![CDATA[<p>That works better. Works perfectly if the data is sorted by the Date field. Works ok if unsorted. </p>
<p>Ideally (this is based on what my client wanted) is that if there were duplicated, but non-contiguous, dates they would show up the same colour. In this version they take on the next value in the custom formatting series.</p>
<p>Thanks for your work on this</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geoff Coffey</title>
		<link>http://sixfriedrice.com/wp/alternating-colors/#comment-1199</link>
		<dc:creator>Geoff Coffey</dc:creator>
		<pubDate>Fri, 06 Jun 2008 20:33:13 +0000</pubDate>
		<guid>http://sixfriedrice.com/wp/alternating-colors/#comment-1199</guid>
		<description>@david:

Sorry. I should have tested first. The problem is that I was playing pretty foot-loose with my error checking because the "not" operator cleaned up any messes all by itself.

When I check the color of the previous record, I don't bother to make sure there &lt;em&gt;is&lt;/em&gt; a previous record. This works fine in the 1/0/1/0 case, but the &lt;code&gt;mod&lt;/code&gt; function isn't happy with this.

So here is a revised version that works properly:

&lt;pre&gt;&lt;code&gt;
Let(
  [previous_record = Get(RecordNumber) - 1;
  previous_color = If (previous_record = 0, 0, GetNthRecord(_COLOR; previous_record))];

  If(GetNthRecord ( DATE ; previous_record ) = DATE;
     previous_color;
     Mod(previous_color + 1; 4)
  )
)&lt;/code&gt;&lt;/pre&gt;

Let me know if that works for you.

Geoff</description>
		<content:encoded><![CDATA[<p>@david:</p>
<p>Sorry. I should have tested first. The problem is that I was playing pretty foot-loose with my error checking because the &#8220;not&#8221; operator cleaned up any messes all by itself.</p>
<p>When I check the color of the previous record, I don&#8217;t bother to make sure there <em>is</em> a previous record. This works fine in the 1/0/1/0 case, but the <code>mod</code> function isn&#8217;t happy with this.</p>
<p>So here is a revised version that works properly:</p>
<pre><code>
Let(
  [previous_record = Get(RecordNumber) - 1;
  previous_color = If (previous_record = 0, 0, GetNthRecord(_COLOR; previous_record))];

  If(GetNthRecord ( DATE ; previous_record ) = DATE;
     previous_color;
     Mod(previous_color + 1; 4)
  )
)</code></pre>
<p>Let me know if that works for you.</p>
<p>Geoff</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Zakary</title>
		<link>http://sixfriedrice.com/wp/alternating-colors/#comment-1198</link>
		<dc:creator>David Zakary</dc:creator>
		<pubDate>Fri, 06 Jun 2008 20:22:24 +0000</pubDate>
		<guid>http://sixfriedrice.com/wp/alternating-colors/#comment-1198</guid>
		<description>Tried the 'mod' version as you suggested. I'm getting question marks in the field as soon as I do.</description>
		<content:encoded><![CDATA[<p>Tried the &#8216;mod&#8217; version as you suggested. I&#8217;m getting question marks in the field as soon as I do.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geoff Coffey</title>
		<link>http://sixfriedrice.com/wp/alternating-colors/#comment-1195</link>
		<dc:creator>Geoff Coffey</dc:creator>
		<pubDate>Fri, 06 Jun 2008 17:22:26 +0000</pubDate>
		<guid>http://sixfriedrice.com/wp/alternating-colors/#comment-1195</guid>
		<description>@david zakary:

I thought about addressing that in the article, but I was getting tired ;)

I think it should be fairly easy. Instead of:

&lt;pre&gt;&lt;code&gt;not previous_color&lt;/code&gt;&lt;/pre&gt;

You would do something along these lines:

&lt;pre&gt;&lt;code&gt;mod(previous_color + 1, 4)&lt;/code&gt;&lt;/pre&gt;

That will give you results that go 0, 1, 2, 3, 0, 1, 2, 3, etc... If you change the &lt;code&gt;4&lt;/code&gt; as the second parameter to something else, you'll get a different number of options in your cycle. Then you just need conditional formatting rules for each possible value.

Geoff</description>
		<content:encoded><![CDATA[<p>@david zakary:</p>
<p>I thought about addressing that in the article, but I was getting tired <img src='http://sixfriedrice.com/wp/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I think it should be fairly easy. Instead of:</p>
<pre><code>not previous_color</code></pre>
<p>You would do something along these lines:</p>
<pre><code>mod(previous_color + 1, 4)</code></pre>
<p>That will give you results that go 0, 1, 2, 3, 0, 1, 2, 3, etc&#8230; If you change the <code>4</code> as the second parameter to something else, you&#8217;ll get a different number of options in your cycle. Then you just need conditional formatting rules for each possible value.</p>
<p>Geoff</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Zakary</title>
		<link>http://sixfriedrice.com/wp/alternating-colors/#comment-1194</link>
		<dc:creator>David Zakary</dc:creator>
		<pubDate>Fri, 06 Jun 2008 15:21:11 +0000</pubDate>
		<guid>http://sixfriedrice.com/wp/alternating-colors/#comment-1194</guid>
		<description>An interesting solution. I had something similar come up before but didn't have a good solution as it was pre-conditional formatting.

This only works with two colours. What if you wanted to have each unique date (or other key data) to show up as a different colour? For in the above example you have 4 unique dates, that would mean 4 colours. 

Any thoughts on how to accomplish that?

My first thought is find some way to count the number of unique dates in the found set, code them as you have and then colour them.</description>
		<content:encoded><![CDATA[<p>An interesting solution. I had something similar come up before but didn&#8217;t have a good solution as it was pre-conditional formatting.</p>
<p>This only works with two colours. What if you wanted to have each unique date (or other key data) to show up as a different colour? For in the above example you have 4 unique dates, that would mean 4 colours. </p>
<p>Any thoughts on how to accomplish that?</p>
<p>My first thought is find some way to count the number of unique dates in the found set, code them as you have and then colour them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Head</title>
		<link>http://sixfriedrice.com/wp/alternating-colors/#comment-1190</link>
		<dc:creator>David Head</dc:creator>
		<pubDate>Fri, 06 Jun 2008 07:46:20 +0000</pubDate>
		<guid>http://sixfriedrice.com/wp/alternating-colors/#comment-1190</guid>
		<description>Excellent lateral thinking and a very cool solution. 

Yet another reason why I love conditional formatting.

Now if you had a scripted sort such that you stored the sort field name, you could make this work based on a variety of sort fields. Hmmm.</description>
		<content:encoded><![CDATA[<p>Excellent lateral thinking and a very cool solution. </p>
<p>Yet another reason why I love conditional formatting.</p>
<p>Now if you had a scripted sort such that you stored the sort field name, you could make this work based on a variety of sort fields. Hmmm.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
