Jump to content
  • 0

Calculating Total with Condition



5 answers to this question

Recommended Posts

  • 0

What if we are trying to add a condition in another way? I need to Sum a Hours column, where another column (Earn_Code) = 1, and another aggregate where Earn_Code = 2.

I also have grouping enabled here. 

I was hoping I could just do SUM(Hours) WHERE Earn_Code = 1, but this is invalid. It seems I need to use a SELECT statement, which would not take the Grouping filter or the dates from the search form into account.

Link to comment
Share on other sites

  • 0

Hello @kpcollier,

You can add a calculated field in the Reports. Then have a CASE WHEN condition that will check if the Earn_Code is equal to 1. If yes, display the value of the Hours. 

CASE WHEN Earn_Code = 1 THEN [@field:Hours] ELSE 0 END

In the Totals and Aggregation, select this Calculated field and select Sum function.

Lastly, you can just hide the Calculated field so it will not be visible in the report.


Hope this helps.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...