Hitachi Vantara Pentaho Community Forums
Results 1 to 5 of 5

Thread: Using formula to change background colour of a rectangle

  1. #1
    Join Date
    Jul 2010
    Posts
    4

    Default Using formula to change background colour of a rectangle

    I would like to use formula to change the background colour of a rectangle depending on whether the page number is even or odd.

    the formula is as follow:
    =if(ISODD(VALUE([PageFunction0]),"yellow","grey") where PageFunction0 is a function defined in the Data panel function section

    However, I would only get yellow when I run the report. Is there anything wrong the formula?

  2. #2
    Join Date
    Oct 2007
    Posts
    235

    Default

    Brackets don't match up if that's an exact copy and paste, you need another one after the end of the VALUE function to close the ISODD function

    Also don't think you need the VALUE() function, but if it works then go with it.

    Good luck

    Wil
    SQL: as much of a standard as the English language

  3. #3
    Join Date
    Jul 2010
    Posts
    4

    Default

    Quote Originally Posted by wselwood View Post
    Brackets don't match up if that's an exact copy and paste, you need another one after the end of the VALUE function to close the ISODD function

    Also don't think you need the VALUE() function, but if it works then go with it.

    Good luck

    Wil
    I think that is not the real issue, my actual formula does have the required bracket and I have tested both with and without the VALUE() function and both return the same result.

    What I did is that I placed a rectangle in the master report watermark and made the watermark sticky so every page will display it. In the Style->bg-color->Formula box, I add the above-mentioned formula to alternate the colour of the rectangle between yellow and grey using PageFunction0, which is a function in the Data->Functions pane. The output of PageFunction0 seems to always be 1.

  4. #4
    Join Date
    Oct 2007
    Posts
    235

    Default

    What version of the reporting engine are you using? I have just tried a simple test and it seems to work ok.

    Created a multi page report, enabled the watermark section, created the page function, dropped a box onto the watermark, ticked the fill box and put
    Code:
    =if(ISODD([PageFunction0]);"green";"red")
    in the text-color box.

    Ended up with a red or green box depending on the page. I also made the default text-colour blue so I could see if the formula was working. I didn't have to make the water mark sticky but then I didn't have any sub-reports.

    Good luck

    Wil
    SQL: as much of a standard as the English language

  5. #5
    Join Date
    Jul 2010
    Posts
    4

    Default

    I have to use sticky as I want to apply the watermark to subreports. Does anybody have the same exprience?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.