[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
Solved

# Compare field results of a shared variable

Posted on 2011-05-12
Medium Priority
222 Views
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!
0
Question by:jph826
• 2

LVL 77

Expert Comment

ID: 35747701
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?
0

LVL 19

Expert Comment

ID: 35748028
Best to give an example of your data and the desired outcome
0

Author Comment

ID: 35749455
Sorry, it's hard to explain and thanks for your patience.  Please see attached print screen example.
example.pdf
0

LVL 19

Accepted Solution

GJParker earned 2000 total points
ID: 35752713

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

``````//@Compare
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'
Else
Result := 'New'

Result
``````

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

``````//@Reset
Shared StringVar Old_Dep := ''
``````

0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…