Reporting and Analytics for Service

Get Involved. Join the Conversation.

Topic

    Janusz Jasinski
    How to check against previous cell/row and highlight rowAnswered
    Topic posted August 14, 2019 by Janusz JasinskiSilver Crown: 22,500+ Points 
    33 Views, 4 Comments
    Title:
    How to check against previous cell/row and highlight row
    Content:

    Hi,

    I am using custom scripts in my report. One column I have values as below:

    1. A
    2. B
    3. B
    4. C
    5. C
    6. C
    7. D
    8. D
    9. D
    10. D

    I would like the row to be a certain colour depending on whether there has been a shift in number. So on the above: 1,2,4 and 7 would have rows of a particular colour.

    What's the best way to go about this?

    I basically want to highlight the latest record for a given row

    Thanks

    Best Comment

    Sebastiaan Draaisma

    See attached row nr example

    Comment

     

    • Sebastiaan Draaisma

      Hi Janusz

      I'm no PHP expert but it may be possible to use the array unique for this

      The array_unique() function removes duplicate values from an array. If two or more array values are the same, the first appearance will be kept and the other will be removed.

      By using a descending sorting it would keep the latest value.
      Then you have the values in your array and are able to use them to highlight the rows in your report through conditional formatting that match those in the array.

    • Janusz Jasinski

      What if I had a single column (let's ignore any other columns) - I'd just have this returned

      1. A
      2. B
      3. C
      4. D

      Which doesn't tell me which row to highlight.

      Let's say I did have two columns, the ID would make everything unique so not sure if this helps

    • Sebastiaan Draaisma

      You would need to use the row nr as your key in the array. You could make the column semi hidden (if desired) by adjusting the width to 5px and by removing the border separating the columns

    • Sebastiaan Draaisma

      See attached row nr example