Trying to get a percentage

  • I'm still working on a projet where I'm converting crystal reports to SSRS. I've ran into this issue. Hopefully someone can help.

    Here's my CR code:

    if(Sum ({Table_Timecard.Hours}, {Table_Employee.EmpID})=0) then 0 else

    (Sum ({Table_Timecard.Hours}, {Table_Client.PrimaryID}) % Sum ({Table_Timecard.Hours}, {Table_Employee.EmpID}))

    This is what I have so far in SSRS:

    =iif(SUM(Fields!Hours.Value, Fields!EmpID.Value)=0, 0,

    (Sum(Fields!Hours.Value, Fields!PrimaryID.Value)) \ (Sum(Fields!Hours.Value, Fields!EmpID.Value)) * 100)

    When I preview the report, I get an error right when I click on Preview.

    What throws me off is the % in CR. Is there something that equals in SSRS?

    Thanks!

  • so what you are after is seeing for a particular row, what percentage that row is of the total?

    I think the functionality you are after is you want to pull that grand total from the group level into the detail level to do the division for the percentage calculation.

    For this, SSRS lets you pass a 2nd parameter in the SUM() function to specify scope. So, you can do something like

    =iif(SUM(Fields!Hours.Value)=0, 0,

    (Sum(Fields!Hours.Value)) / (Sum(Fields!Hours.Value, "group_id")) * 100)

    where "group_id" is the name of your group. and yea it has to be in double quotes. If you don't specify the scope of the sum like that, it applies to the row level.

    Hope that helps.

  • getoffmyfoot (10/1/2010)


    so what you are after is seeing for a particular row, what percentage that row is of the total?

    I think the functionality you are after is you want to pull that grand total from the group level into the detail level to do the division for the percentage calculation.

    For this, SSRS lets you pass a 2nd parameter in the SUM() function to specify scope. So, you can do something like

    =iif(SUM(Fields!Hours.Value)=0, 0,

    (Sum(Fields!Hours.Value)) / (Sum(Fields!Hours.Value, "group_id")) * 100)

    where "group_id" is the name of your group. and yea it has to be in double quotes. If you don't specify the scope of the sum like that, it applies to the row level.

    Hope that helps.

    THANKS!!

    My manager and I just figured it out right after I posted it. Here's what we used:

    =(Sum(Fields!Hours.Value, "PrimaryID")/Sum(Fields!Hours.Value, "EmpID")) * 100

    We left out the IIF statement and we got the results we were looking for.

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

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