Doing math functions in Report Services

  • First, I hope I am in the correct section (my appologies if not)

    What I need to do is take all the values of a field that is dynamic based on age in groups that are called "Over 80", "71-79" and  "70 and under"

    What I want to do is count all of the area's then multiply that by a rate to get how much it would cost of XYZ product based on Age Range of one of the three above.  I get an error when I run this.

    or if I could ask it for dob_age(Which is the calculated Age) saying something like this

    If dob_age >= 80 Then (Sum of all persons over 80) *.63

    If dob_age between 71 and 79 then (sum those people) *.57

    if dob_age <= 70 then (sum those people) * .51

    Here is what I was trying amonst other things but it doesn't work.

    This is a text box with an expression in it.

    =Sum(Fields!ind_age_cp.Value >= 80)*.063

  • That's how I'd do it server side... maybe that can be applied is SSRS :

    SUM(CASE WHEN dob_age ­­>= 80 THEN 1 ELSE 0 END) AS X80

    SUM(CASE WHEN dob_age ­­< 70 THEN 1 ELSE 0 END) AS X69

    SUM(CASE WHEN dob_age ­­>= 70 and dob_age < 80 THEN 1 ELSE 0 END) AS X70_80

     

    This gives you the counts for each categories pivoted in columns.  If you only need them by rows, then a group by using the case statements will work.

  • I am not seeing where the math is at.  That looks like it will give me a value of X80 , etc but how do I take that number and multiply it by  another number

  • SUM(CASE WHEN dob_age ­­>= 80 THEN 1 ELSE 0 END) * WhateverHere AS X80

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply