<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>RE: Conditional Formatting</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>Julian,<BR>
<BR>
I'm not sure what you mean by adding it to Mondrian since the parsing is done by the OLAP client who reads the cell formatted value.&nbsp; I've added unit tests to Analyzer already.<BR>
<BR>
Here's the snippet from Analyzer:<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String formattedValue = cell.getFormattedValue();&nbsp; // Apply format defined on measure such as $#,##0.00<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (formattedValue.startsWith(&quot;|&quot;))<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String[] strs = formattedValue.substring(1).split(&quot;\\|&quot;);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; formattedValue = strs[0]; // original value<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int i = 1; i &lt; strs.length; i++) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String propName = null;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String propValue = null;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Matcher m = regex1.matcher(strs[i]);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (m.matches()) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; propName = m.group(1); // property name<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; propValue = m.group(2); // property value<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; properties.put(propName, propValue);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; continue;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m = regex2.matcher(strs[i]);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (m.matches()) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; propName = m.group(1); // property name<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; propValue = m.group(2); // property value<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; properties.put(propName, propValue);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; continue;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // it is not a key=value pair<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // we add the String to the formadded value<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; formattedValue += strs[i];<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
<BR>
The two regex are as follows:<BR>
<BR>
private Pattern regex1;<BR>
private Pattern regex2;<BR>
...<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; regex1 = Pattern.compile(&quot;\\s*([a-zA-Z][\\w\\.]*)\\s*=\\s*'([^']*)'&quot;);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; regex2 = Pattern.compile(&quot;\\s*([a-zA-Z][\\w\\.]*)\\s*=\\s*([^\\s]*)&quot;);<BR>
<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: Julian Hyde [<A HREF="mailto:jhyde@pentaho.com">mailto:jhyde@pentaho.com</A>]<BR>
Sent: Tue 6/15/2010 6:23 AM<BR>
To: Benny Chow<BR>
Cc: mondrian@pentaho.org<BR>
Subject: RE: Conditional Formatting<BR>
<BR>
Great.<BR>
<BR>
If you feel like throwing the parsing code over the wall to me, I will add<BR>
it to mondrian. Maybe add a couple of unit tests too. &quot;The tests are the<BR>
specificiation&quot; and all that good stuff.<BR>
<BR>
Julian<BR>
<BR>
<BR>
&nbsp; _____&nbsp;<BR>
<BR>
From: Benny Chow [<A HREF="mailto:bchow@pentaho.com">mailto:bchow@pentaho.com</A>]<BR>
Sent: Monday, June 14, 2010 7:41 AM<BR>
To: Julian Hyde<BR>
Cc: mondrian@pentaho.org<BR>
Subject: RE: Conditional Formatting<BR>
<BR>
<BR>
<BR>
I looked at the JPivot source code and indeed it looks for a leading &quot;|&quot;.<BR>
After that, JPivot splits whatever Mondrian returns from<BR>
cell.getFormattedValue using &quot;|&quot; as the separator.&nbsp; JPivot then applies a<BR>
regular expression to find name value pairs separated by a &quot;=&quot;.&nbsp; The name<BR>
part corresponds to &quot;style&quot;, &quot;link&quot;, &quot;arrow&quot; or &quot;image&quot; as described here:<BR>
<A HREF="http://jpivot.sourceforge.net/news.html">http://jpivot.sourceforge.net/news.html</A> -&gt; Member Properties<BR>
<BR>
<BR>
<BR>
I'm going to keep the same standard for Analyzer since it means people can<BR>
re-use their JPivot mondrian schemas with Analyzer and keep their cell<BR>
formatting.<BR>
<BR>
<BR>
<BR>
Benny<BR>
<BR>
<BR>
<BR>
<BR>
&nbsp; _____&nbsp;<BR>
<BR>
<BR>
From: Julian Hyde [<A HREF="mailto:jhyde@pentaho.com">mailto:jhyde@pentaho.com</A>]<BR>
Sent: Sunday, June 13, 2010 12:04 AM<BR>
To: Benny Chow<BR>
Cc: mondrian@pentaho.org<BR>
Subject: RE: Conditional Formatting<BR>
<BR>
<BR>
<BR>
Yes, there is a semi-standard way of formatting values to include style<BR>
information. I believe that it started with Micrsoft OLAP Services, and for<BR>
JPivot we adopted the same standard. (Although now when I search, most of<BR>
the examples using this are Mondrian-related.)<BR>
<BR>
<BR>
<BR>
I believe that the leading '|' is the clue that style information is<BR>
present. But the standard is essentially arbitrary, and I don't know whats<BR>
supposed to happen if the formatted value actually starts with a '|'.<BR>
<BR>
<BR>
<BR>
You could start a new standard. It's definitely possible to return the style<BR>
in a different calc member. As long as you document what analyzer is<BR>
expecting.<BR>
<BR>
<BR>
<BR>
Julian<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
&nbsp; _____&nbsp;<BR>
<BR>
<BR>
From: Benny Chow [<A HREF="mailto:bchow@pentaho.com">mailto:bchow@pentaho.com</A>]<BR>
Sent: Saturday, June 12, 2010 7:41 AM<BR>
To: Julian Hyde<BR>
Subject: Conditional Formatting<BR>
<BR>
Hi Julian,<BR>
<BR>
<BR>
<BR>
I'm looking into some conditional formatting for Analyzer and I tried out<BR>
your suggestion in this forum post you made:<BR>
<BR>
<BR>
<BR>
<A HREF="http://forums.pentaho.org/showthread.php?t=47222">http://forums.pentaho.org/showthread.php?t=47222</A><BR>
<BR>
<BR>
<BR>
<BR>
<BR>
&lt;CalculatedMember<BR>
name=&quot;Profit&quot;<BR>
dimension=&quot;Measures&quot;<BR>
formula=&quot;[Measures].[Store Sales] - [Measures].[Store Cost]&quot;&gt;<BR>
&lt;CalculatedMemberProperty name=&quot;FORMAT_STRING&quot; expression=&quot;<BR>
Iif([Measures].[Profit] &lt; 100000, '|$#,##0.00|style=green',<BR>
'|$#,##0.00|style=red')&quot;/&gt;<BR>
&lt;/CalculatedMember&gt;<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
For the cell that has this member as its context, suppose Profit is 100.<BR>
Will cell.getFormattedValue return $100.00 or |$100|style=green ?&nbsp; I am<BR>
currently getting the ladder.&nbsp; If the ladder is correct, is JPivot doing<BR>
some post processing by parsing the formatted cell value and then showing<BR>
the $100 in HTML and then applying the other stuff like style=green as a CSS<BR>
attribute?&nbsp;<BR>
<BR>
<BR>
<BR>
Maybe there is some special handshake that's going on between Mondrian cell<BR>
formatting and JPivot that makes the conditional formatting work.&nbsp;<BR>
<BR>
<BR>
<BR>
Any insight would be much appreciated.<BR>
<BR>
<BR>
<BR>
Thanks<BR>
<BR>
Benny<BR>
<BR>
<BR>
<BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>