• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 411
  • Last Modified:

SSRS Expression

Hi,

I am trying to build an expression in SSRS to do the following:

I have 5 fields that are involved. BenefitPlanCode, KronosEmprContribution, KronosEmpDeduction, TotalEmployeePremium and Amount (plus the expression field)

If BenefitPlanCode = "LIFETX" and (KronosEmprContribution<> Amount) then expression field = "LIFETX MISMATCH"
If BenefitPlanCode = "MEDICAL COPAY" and (KronosEmpDeduction<> Amount) then expression field = "MEDICAL COPAY MISMATCH"
If BenefitPlanCode = ("MEDICAL") and (TotalEmployeePremium<>Amount) then expression field = "MEDICAL MISMATCH"

I tried the following switch function but it doesn't work properly even though it doesn't generate an error:

=Switch(Fields!BenefitPlanCode.value = "LIFETX" and
Fields!KronosEmprContribution.Value<>Fields!Amount.Value,"LIFETX MISMATCH",Fields!BenefitPlanCode.value = "MEDICAL COPAY" and
Fields!KronosEmpDeduction.Value<>Fields!Amount.Value,"MEDICAL COPAY MISMATCH",Fields!BenefitPlanCode.value = "MEDICAL" and
Fields!TotalEmployeePremium.Value<>Fields!Amount.Value,"MEDICAL MISMATCH")

Can someone help please?

Thank you :)
0
hackman122
Asked:
hackman122
  • 2
  • 2
  • 2
2 Solutions
 
Koen Van WielinkIT ConsultantCommented:
You say that "it doesn't work properly even though it doesn't throw an error". I guess this implies that the expression is correct (seems ok to me), but that the output is not what you're expecting? Can you clarify? Could it be that you have part of the switch statement evaluating to True before you expect it to happen? Please explain why it's not working "properly".
0
 
hackman122Author Commented:
Only the first part returns results ("LIFETX MISMATCH"). I don't get any "MEDICAL COPAY MISMATCH" or "MEDICAL MISMATCH" even though there should have been some.

Thanks.
0
 
Koen Van WielinkIT ConsultantCommented:
Can you provide some sample data where you would expect to see at least 2 different outcomes? Which version of SSRS are you using by the way?
Is this expression in the details section of the report or part of a group?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
planoczCommented:
Are these fields all in the same textbox or are you having 3 different textboxes?
KronosEmprContribution, KronosEmpDeduction, TotalEmployeePremium
0
 
planoczCommented:
If the 3 different values are all in the same textbox try this.....

IIf(Trim((Fields!BenefitPlanCode.Value) = "LIFETX" And (Fields!KronosEmprContribution.Value<> (Fields!Amount.Value), "LIFETX MISMATCH", _
        IIf(Trim((Fields!BenefitPlanCode.Value) = "MEDICAL COPAY" And (Fields!KronosEmpDeduction.Value <> (Fields!Amount.Value), "MEDICAL COPAY MISMATCH", _
        IIf(Trim((Fields!BenefitPlanCode.Value) = "MEDICAL" And (Fields!TotalEmployeePremium.Value <> (Fields!Amount.Value), "MEDICAL MISMATCH", "0")))
0
 
hackman122Author Commented:
The error was somewhere else and I figured it out. Thanks for your help though guys!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now