Hitachi Vantara Pentaho Community Forums
Results 1 to 8 of 8

Thread: Write a field value in details band ONLY IF is different from previous

  1. #1
    Join Date
    Mar 2012
    Posts
    14

    Lightbulb Write a field value in details band ONLY IF is different from previous

    Hi everyone. My report looks like:

    Code:
    John Doe | Area one |  23
    John Doe | Area two | 678
    Jack Til | Area one |  12
    Jack Til | Area two | 567
    Is it possible to display the same data, but hiding names when equal to previous row, ie:

    Code:
    John Doe | Area one |  23
             | Area two | 678
    Jack Til | Area one |  12
             | Area two | 567

  2. #2

    Default

    you create a group on username (or most likely userID), and take the firstname/lastname out of the details band.

    _________________
    Group Band First Name/Last Name
    _________________
    Details Band Area/Value
    _________________

  3. #3
    Join Date
    Mar 2012
    Posts
    14

    Default

    Quote Originally Posted by sfrattura View Post
    you create a group on username (or most likely userID), and take the firstname/lastname out of the details band.
    Sure I could, but name will not be on the same line with the first row.

  4. #4
    Join Date
    Nov 2009
    Posts
    687

    Default

    Use the formula HASCHANGED() and put that in the value. It then would be something like :=IF(HASCHANGED("Name"); [Name] ; " ")
    An example you can find in ..\report-designer\samples\Operational Reports\inventory.prpt

  5. #5
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    Or use the most simple option:

    On your field, go to the attributes-table, and set the "wizard:show-changes" attribute to true. This shows only the first changed value. It also handles pagebreaks (so that the value is always printed at the beginning of a page) and groups (forces values to be printed on the first line after a group has started).
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

  6. #6
    Join Date
    Mar 2012
    Posts
    14

    Default

    Thank you! Great!

  7. #7

    Default

    then you have to do it in your SQL statement. Here is a demo:

    _____
    create table demo(name varchar(20), area varchar(20), amount int);
    insert demo values ('John Doe', 'Area One', 23);
    insert demo values ('John Doe', 'Area Two', 678);
    insert demo values ('Jack Til', 'Area One', 12);
    insert demo values ('Jack Til', 'Area Two', 567);
    _____


    select * from demo;

    | name | area | amount |
    | John Doe | Area One | 23 |
    | John Doe | Area Two | 678 |
    | Jack Til | Area One | 12 |
    | Jack Til | Area Two | 567 |



    ________________
    set @name = ''; select *, if(@name=name, '-----', name) displayName, @name:=name assignNameVar from demo;
    | name | area | amount | displayName | assignNameVar |
    | John Doe | Area One | 23 | John Doe | John Doe |
    | John Doe | Area Two | 678 |
    ----- | John Doe |
    | Jack Til | Area One | 12 | Jack Til | Jack Til |
    | Jack Til | Area Two | 567 |
    ----- | Jack Til |

    (i am not sure the query above with work in PRD, so you might have to make it a stored procedure. This uses the concept of an inline local variable.

    That variable keeps track of the value of the prior column you care about, and compares it to the current column.

    IF SAME->"----"
    ELSE DIFFERENT-><COLUMN>

    (note: I used "----" for readability, you could use an empty string '')

  8. #8
    Join Date
    May 2012
    Posts
    13

    Default

    Great! What a pity it don't work with 'messages', does it? Although messages have this attribute as well...

    Quote Originally Posted by Taqua View Post
    Or use the most simple option:

    On your field, go to the attributes-table, and set the "wizard:show-changes" attribute to true. This shows only the first changed value. It also handles pagebreaks (so that the value is always printed at the beginning of a page) and groups (forces values to be printed on the first line after a group has started).

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.