Compare field results of a shared variable

Posted on 2011-05-12
Last Modified: 2012-06-27
I have a Crystal Report based on a table that uses a shared variable field and each field value is associated with a sequence number.  For example:

each {WFVARIABLE.WF_SEQ_NBR} will have a {WFVARIABLE.VARIABLE_VALUE},  For example seq nbr 4 is "old dept", seq nbr 5 is "new dept".

I need a formula that compares the values of seq 4 and seq 5.  Something that says if the value of seq nbr 4 does not match the value of seq nbr 5 then "N".

I have several different seq nbrs and values I need to compare, so any help would be most appreciated.  Thanks!
Question by:jph826
    LVL 77

    Expert Comment

    I don't understand what you are describing.

    If ...  "seq nbr 4 is "old dept", seq nbr 5 is "new dept"."  ...  then how can seq nbr 4 ever be equal to seq nbr 5?
    LVL 19

    Expert Comment

    Best to give an example of your data and the desired outcome

    Author Comment

    Sorry, it's hard to explain and thanks for your patience.  Please see attached print screen example.
    LVL 19

    Accepted Solution


    To be able to do this using your resultset you will need to ensure that the old_department record is always before the new department record.

    If this is true then try adding this formula on to the report

    Shared StringVar Old_Dep;
    Local StringVar Result;
    If {WFVariable.Variable_Name} = 'Old_Department' Then
        Old_Dep := {WFVariable.Variable_Value}
    Else If {WFVariable.Variable_Name} = 'New_Department' Then
        If {WFVariable.Variable_Value} = Old_Dep Then
            Result := 'Same'
            Result := 'New'

    Open in new window

    If you have a group on WorkUnit then you will also need to add a formula to the group header section to reset the Old_Dep variable

    Shared StringVar Old_Dep := ''

    Open in new window



    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
    I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now