CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 1 of 1
  1. #1
    Join Date
    Feb 2015

    Crystal Reports 2013: Creating a Formula with filters to run a calculation

    Hello All,

    I hope this is an easy one for you. I am stomped. I use Crystal Reports 2013 for Reporting Service Desk Tickets. I would like to run a formula only when an item is a certain category. I can create a record selector and limit the category, but then I would need to create a bunch of sub-reports because other formulas in my report should not display filtered criteria. I am missing some kind of "Select from" statement. This is what I would like to obtain from the formula:

    If {Category} = "Major" and {Status} = "Closed" then avg({Deployment Hours}) else
    If {Category} <>"Major" and {Status} <> "Closed" then 0

    Issue: If my criteria is met, the formula will average all [Deployment Hours] and not limit the average to only items with a [Category] = "Major" and [Status] = "Closed".

    I can obtain the info using a cross-tab, but I wanted to save space on the report. I wanted to obtain the result using a formula. Does anyone know how to see the formula used by a cross-tab? If I can see what formula the cross-tab is using, I can solve my answer.

    Background: Each ticket has a category. I can obtain results for how many Major are Closed. I can obtain the Average of all Deployments, but I would like to only run the avg([Deployment Hours]) for tickets that are Closed and are Majors.
    {Category} = text
    {Status} = text
    {Deployment Hours} = number

    After doing some research on Case Statements for Crystal Reports, I think I am on the right track. Can someone verify if the below statement is correct? My statement is looking at all Closed Status. When there is a Closed item that is classified as Major, the calculation "avg{Deployment Hours}" will be ran only for the Closed/Major items.

    select {Closed Status}
    case {Major Category}:
    avg{Deployment Hours}
    Last edited by jnole; February 17th, 2015 at 12:58 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width