Using a subreport field in a main report formula.

Post Author: testing123
CA Forum: Formula
Hi.I have a summary of a field {timesheet_log.labour_cost} in a subreport and a field {project.total_po} in the main report and I want to add the two together in a function in the main report. Both fields are linked to a job which is grouped by the jobs' ID.The subreport contains this formula: shared CurrencyVar myTotal;myTotal := Sum ({timesheet_log.labour_cost}); In the main report I have a formula, myTotal, that reads: WhilePrintingRecords;shared CurrencyVar myTotal;myTotal;  As you can see myTotal is a shared variable which contains the total of all the values in {timesheet_log.labour_cost}. However, when I put the formula myTotal in the group footer for each project, it will only change if there is an actual set of values in {timesheet_log.labour_cost}. If there isn't, it will display the last total of {timesheet_log.labour_cost}. We get something like this: Job           Sum{timesheet_log.labour_cost}           {project.total_po} 10050       0   (no value)                                                  100       10051        400    (Value = 400)                                    492210052        400    (no value)                                              32910053      400   (no value)                                    1111110054      2490 (Value = 2490)                                     24210056      6000 (Value = 6000)                            343410057      6000 (no value)                                    99494 Basically what this is saying is that if there are no values at all (ie NULL) in {timesheet_log.labour_cost}, the formula I have made will use the previous value. What I want to do is set the Sum({timesheet_log.labour_cost}) to zero if there are no labour_costs so that basically the value is reset to 0 if there's nothing there.                           

Post Author: JKitz
CA Forum: Formula
Group it by Job Number and then add the following to the group header:  WhilePrintingRecords;shared CurrencyVar myTotal := 0 Then put the information you have above in the group footer with your formula and suppress the detail section.  That way you will zero it out with each new Job Number

Similar Messages

  • Summary field of subreport used in main report formula calculation

    I have a summary field in a subreport that I want to use in a calculation of a percentage using a second summary field in the main report as the denominator.  How do I do this in a new formula?

    Thank You Ian Waterman,...
    Couple of questions:
    Where you say "... in subreport
    @ eval
    whileprinting records;
    shared number x:=your summary
    Am I correct that this is to be a new formula created in the subreport design?
    What should I put for the "x" in the formula?
    Should the "your summary" be:  "DistinctCount of Activated_Survey.Seq.Incident"  which I have showing in the Report Footer of the subreport?
    Where in the subreport should I place the formula?  Can it be hidden?
    Where you say "In subreport header..."
    @reset
    whileprintingrecords;
    shared number x:=0
    Am I correct that this is to be a new formula created in the subreport design?
    What should I put for the "x" in the formula?
    Where in the subreport should I place the formula?  Can it also be hidden?
    Where you say "In the main report in section after subreport..."
    I have the subreport sitting up in the main Report Header as I only want the subreport summary field showing. 
    In the subreport, I have the Report Header and Details section hidden.
    @calc
    whileprintingrecords;
    (shared number x / main report summary) * 100
    Am I correct that this is to be a new formula in the main report?
    However, what I need to have happen is that the main report summary field of: "Count of Answered_Survey.Seq.Incident" needs to be divided by the subreport summary field of "DistinctCount of Activated_Survey.Seq.Incident" * 100.
    What do I modify in the formula?
    Thanks.

  • Multiple subreports within a single main report?

    I'm a newbie to BI Publisher, but have used Crystal Reports quite a lot.
    I have a requirement which essentially consists of a set of 7 similar and closely related reports, each using a different SQL Select statement and printing different columns; the user will have the option of selecting either one of the 7, or all of them.
    In Crystal Reports I would set up 7 subreports within a single main report, and depending on the parameter, suppress those subreports which are not required.
    Is there a technique within BI Publisher which would enable me to achieve the same thing?

    all the sub templates will go against a single XML. So if your sub reports in CR is handling different query, you need to take a step back and think of separating data and layout. So multiple queries will be handled by data templates. So, for example, if your main report fetches some records as Q1 query, and you have two sub templates with queries as SQ1, SQ2 (linked subreport). Then we have to see what relationship exists between the main report and the subreport. Say, the sub report query creates a relationship with the Main report data, to filter certain records. So this can be achieved in data template using Q1 and SQ1 using bind relationship, ie, Q1 is master query and SQ1 is a detail query. Similarly Q1 and SQ2 relationship can be established. The datatemplate when executed, will fetch a single XML data.So in this case you do not need sub template. The sub-report layout is not separate, and is to be created with the main report.
    In case of unlinked subreport, the content of subreport is independent of main report, so you can simply define two datasets in BI Publisher and then select the Concatenation option. So the final XML data will be a concatenation of two XML data. The main report can read data of the main XML and the sub template can read data from the appended XML data. This can be done using xPath.

  • How to use a subreport field as selection criteria for the main report

    Dear All,
       I created a report with one subreport and im comparing information from both reports but i need to apply selection criteria in the main report using one of the fields in the subreport, the problem is that the subreport field doesnt appear in the select expert screen. By any chance, someone knows how make a subreport field be used by the select expert.
    Thanks,
    Martha Medrano

    Dear Dom,
       I created the subreport table called IIM (748 items) in sql in the main report as you suggested with the below code:
    SELECT "IIM"."IPROD", "IIM"."IDESC", "IIM"."IID"
    FROM   "S102F360"."BPCS405CDF"."IIM" "IIM"
    WHERE   NOT ("IIM"."IDESC" LIKE 'GEN%' OR "IIM"."IDESC" LIKE 'OBS%') AND "IIM"."IID"<>'IZ' AND "IIM"."IPROD" LIKE '3%'
    and i have another table called ITEM_MASTER (3221 items):
    SELECT "ITEM_MASTER"."ITEM_ID", "ITEM_MASTER"."DESCRIPTION"
    FROM   "WHSPRO"."dbo"."ITEM_MASTER" "ITEM_MASTER"
    ORDER BY "ITEM_MASTER"."ITEM_ID"
    and im trying to display all items in the ITEM_MASTER table that are not in the IIM file but i haven't been able to accomplish this, i am using as primary the ITEM_MASTER table with 'Inner Join' as Join Type,  and '!=" as Link Type. Do you have any ideas on how can i display the requested items.
    Thanks for your help

  • Can subreports use same selection parameter(s) as main report?

    Hi,
    Is it possible to create subreports that use the selection selection parameter(s) as the main report.
    And if so, would the user need to make their selections twice, or just once when they open the report?
    Thanks, Jon

    Hi
    Yes you can use the same parameter for both your subreport and the main report with running the parameter just once,.
    Create a parameter in your main report and link the same field(for which you have created the parameter) of subreport with this parameter.
    Now when you refrresh the report, you would input the values and the subreport would also return records based on those values.
    Note that this is simple when you are using same datasource and tables for both subreport and main report. Otherwise you need to have same structures for tables and data type as well for subreport and the main report.
    Hope this helps!!
    Regards
    Sourashree

  • Using a subreport formula in a main report formula

    Hello,
    I am trying to use a formula that is in the subreport and also a formula that is in my main report to come up with a percentage.
    ve researched the forums on the internet and couldn't find anything that directly fit my situation.
    - Formula #1: The SubReport formula is the "sum" of a number variable of {JobRecord.ProjectedIssueDate}. This is for the actual amount of job issued.
    - Formula # 2: The MainReport formula is the "sum" of a number variable of {JobHours.StartDate}. This is for the actual amount of jobs completed.
    Issue: I need to create a formula to take the Formula # 1 and Formula # 2 and get a percentage.
    Example:
    9 Jobs Completed in Main Report / 10 Jobs Projected in Sub Report = 90%
    My main report is grouped as follows for both the main and sub report:
    Grouping #1: Start Date
    Grouping #2: Contractor Code
    Grouping #3: Job Type Code
    I need this formula to work on the Grouping # 3 Level.
    Any takers?

    Also, If you want the Percentage and Sum from the Subreport to show beside each other, here's what you need to do:
    1) Create a new Group header 3b section
    2) Move everything except the Subreport on the Group Header 3b section
    3) Get inside the Subreport and suppress all sections of the Subreport
    4) Back in the Main Report reduce the size of this Subreport and make this no bigger than a dot. Reduce the size of the section so it doesn't take up a lot of space.
    5) Create a formula with this code:
    shared numbervar cnt;
    Drag and drop this formula on the Group header 3b so that this shows the sum from the Subreport.
    -Abhilash

  • Crystalrep:how to use the summary of subreport to calculate in main report

    mainreport  main  main  sub      sub   main
    Salesman      sales    Cost   Travel   Taxi   Margin
    A1             100       50       20       20     sales-cost-travel-Taxi
    A2             200       100     20       20     sales-cost-travel-Taxi
    A3             300       200     40       30     sales-cost-travel-Taxi
    eg.: A1 margin=100-50-20-20=10
    main report linked to subreport by salesman and confirmed the data in report is correct. but the summary of travel and taxi is from subreport, if i want to calculate the margin, the travel and taxi can not be insert to the formula, only sales and cost can be calculated
    how can i process travel and taxi ?

    If you search the kbases (articles) for "c2007600" or "how to share subreport data with main report" you'll find what you need.
    NOTE:  One can NOT use data from a subreport object in a section in the main report that is previous to the section in which said subreport is located.

  • Issues once subreport is added to main report.

    Another question from a new Crystal Reports Developer. I have been battling this one for multiple days. I have built two seperate reports through Crystal Reports that pull their data through an ODBC connection from Remedy ITSM. One report is pulling data through the table AST_AssetPeople. It is pulling the following fields: Asset_ID and Full_Name. The other report is pulling data from the AST_ComputerSystem table showing the following: Name, Category, Type, Item, Model_Number, Serial_Number. I am using the AssetPeople report as the main and the ComputerSystem report as the subreport. When I pull the ComputerSystems report into the AssetPeople report as a subreport, my CR lags very badly. I let CR attempt to pull the data for about 2 hours before I left work the other day and ended up having to leave it overnight. When I came back to work the following day it had finally completed and I was able to view all pages of data. This is with the subreport being added to the details section of my main report. I had sent it to someone else at work that has Crystal Reports on their PC and they were able to run it just fine and it only took a few minutes to get all pages of the data back and viewable. That lead me to think that it was my PC, but when I went over to the other persons PC and logged in with my profile, I had the same problem that I had on my PC. This leads me to believe that it is an issue with the settings. The other person is out for the next week so I cannot verify that my settings match his, so I was wondering if anyone on here might have an idea what may be causing the issues that I am having. Both reports run just fine on their own, as do all my other reports that are simple reports from one table. It is just when I try to pull in a subreport that I have this issue. Any help would be greatly appreciated.

    I have gone in and checked the box next to Perform Grouping on Server. The check box next to Use Index or Servers for Speed was already checked. The Links for the subreport are set up as follows.
    For subreport: Supported vs. Unsupported (This one comes from the ComputerSystem table)
    Container Report fields to link to: AST_AssetPeople.Asset_ID
    AS_AssetPeople.Asset_ID field link-
    Subreport parameter field to use: ?Pm-AST_AssetPeople.Asset_ID_
    Select data in subreport based on field: AST_ComputerSystem.Asset_ID_
    Asset ID is the only field that I found that the two tables have in common. I believe that I have the links set up correctly, but I could be wrong.
    Either way, I am still having the same problems.

  • SubReport Data in a Main Report Yet Again

    I have been trying and reading posts all day.
    1. The shared variable formula used in the main report will show any/correct value only if its placed atleast 1 section below the one where the sub report exists. (I've Done This)
    2.The formula that is used inside the sub report needs to be physically placed on any of the sections within that sub report(you can suppress it to avoid displaying the value). (I've Done This)
    3. Due to design constraints if you cannot move the sub reports from Report Footer then you can atleast mock them and place respective copies in the Report Header.These can contain just the summary values, thats it. Further, to nullify the display effect you can suppress all the sections of these sub reports and make them so small such that they appear as tiny dots and place them in extreme corners of the Report Header section. (Not sure this would apply since I have met #1 and #2)??
    The blue outline/highlight is the passed total from by first subreport locatd in Group Header 1b. As you can see it is passing 0.
    In the subreport, here is the formula used to get the OrderQty.
    WhilePrintingRecords;
    Shared NumberVar OrderQty;
    OrderQty := OrderQty + {iptrn.ipqord}
    I am using the "three part" formula to to calculate the Qty because when using a sum it sums up all records and I need to to sum by change in item. The subreport is calculating correctly. I have also tried a running sum but this won't pass either and I get messages about not being able to use the formula with itself so gave up that avenue.
    In the main report, here is the formula used to display the OrderQty.
    WhilePrintingRecords;
    Shared NumberVar OrderQty;
    OrderQty
    //@MainFormula
    //Returns the value that was stored in the shared number variable called
    //OrderQty in the subreport
    I think I have this all correct but still getting zero so i am not sure if it has something to do with resetting the value and maybe my linkages are not correct? Any help will be appreciated. I have very little experience with Crystal and less with sub reports.

    Ok, so I used the example sent and I can't really tell you why it worked but it did. The modifications I made were so minor I would never have expected it to work.
    here is one
    Mine
    WhilePrintingRecords;
    Shared NumberVar OrderQty;
    OrderQty := OrderQty + {iptrn.ipqord};
    Yours
    whileprintingrecords;
    shared numbervar OrderQty;
    OrderQty:=OrderQty + {iptrn_.ipqord}
    The only difference I see other than the capitalization is the space after OrderQty :=.  My numbers were working fine on the sub report, they just wouldn't pass to the main report.  I did move the reset to the page header like your example but I don't understand why that even works when it should reset on the item, not the page..??? I also put the details variable in a second detail section like you had in the example. What is the theory behind this?
    I also had a second one that I needed so I set that up exactly as the first one and no go. I had to move the reset into the GH1 and I put the details variable in a second detail section and it too worked.
    I can't say that I understand why......I'm happy it works but it would be nice to know the why so next time I wouldn't struggle with it

  • Hi ,Multiple SubReport parameter  in one main Report

    Hi,
    I using one main report in that five to six sub report and each sub report have two parameter fromdate and todate so please guide me how can i pass using coding.
    Regards
    Rajkumar Gupta

    Hi
    Please post your query in the SDK development forum.
    Follow the link below:
    https://www.sdn.sap.com/irj/sdn/businessobjects-sdk-forums
    Thanks

  • Display Subreport Totals in the Main Report

    I am using CF10 Report Builder. I have a main report that show counts/amounts by award type for admitted and deposited students. I have a sub report that shows counts/amounts by award type and level for current students who have registered and those who have not yet registered. I need to show the totals of current students by level and weather they have registered or not.
    I tried adding a sub report to show the totals but the sub report does not show up on the main report. Is there a way to do this that I am missing?

    I created the sub-report because the award information is kept in separate
    tables for incoming and returning students. I will work on combining the
    the two.
    Thanks
        Bonni
    Bonni Harris
    Database Analyst
    Eureka College
    300 E. College Avenue
    Eureka, IL 61530-1500
    309-467-6467
    On Tue, Apr 28, 2015 at 12:25 PM, EddieLotter <[email protected]>

  • Behavior on subreport totals in the main report

    I have a grouped report which receives two totals from each grouping's subreport via shared variables.  In the main report I show the subreport totals for each group but cannot find a way, in the main report, to add the subreport totals together to become a report grand total.  The running totals feature does not see the returned subreport totals and I cannot find a formulaic way of achieving a grand total.  Has anyone managed this?  Any help is much appreciated.

    Lets step back a moment and see, you got Sub report places in say GF1 section. I suppose this formula of SV in the sub report is placed in the RF of the sub-report right ? what you might have to do is Change the sub report SV to assign it to a Running total...
    The subreport SV is:
    WhilePrintingRecords;
    Shared CurrencyVar
    AmountSpentRunningTot := #RTOTAL0 ({QuoteMaterials.qmmMinimumCharge})
    **You might have to create a separate SharedVariable with some different name, place it in the RF of the SUBreport
    Now I am guessing that this sub report repeats N times..for N number of GF in the main report...you might have to make a manual running total where you capture and add the 'GrandRunningTotal' coming from Sub report in every GF of the main report and then display it in the main report(s) RF...
    hope i made sense...its little complicated to put it out in words...

  • Using SubReport to show Details of field grouped in Main Report

    Hi Experts
    I am creating a Crystal Report from BEx Query . In Report i have Created a group on Cost center field.
    & some other fields are in detail section. Suppose if i execute report then groups are A, B, C, D ......
    Now further requirement  is  when i click on one group for example 'A' then i should get detail of that group in
    different subreport.
    Is it possible?
    Regards
    Ajay

    Hi Ajay,
    Follow this Steps,
    1,Create a Group with 'Cost center'.
    2,Delete the 'group name'(A,B,C...) form 'group header'. Now you will get a group with no headings.. which means GH #1 section should be blank for now.
    3, Insert the OnDemand subreport in to the Group header.(The same place which we have Group header name before)
    4,Set "Subreport link as "Cost center". (Right click on subreport>Change subreport links>double click on 'Cost center' in report feilds-->OK)
    5,Now the important thing,  Change the "On-Demand Subreport Caption " as group name.
    (Right click on subreport>Format subreport>Subreport Tab>Click in 'X-2' button of  "On-Demand Subreport Caption ">Formula editor will popup, then right like
    GroupName ({Cost center}) // Or double click on the Group #1 Name in the Report Fields tree in Field tree-->Save And Close)
    6, Change the font,Font Color an d uncheck the underline.
    This will work for you,
    Regards,
    Salah.
    Edited by: salahudheen muhammed on Sep 23, 2009 11:53 AM

  • Use subreport total in formula in main report

    Hi,
    I have a subreport which is a total figure. I just want to muliply this by a number in a field on the main report, can this be done?
    Any help appreciated!

    Symptom
    A report contains a subreport. Data from the subreport is required for calculations in the main report.
    How can you share subreport data with the main report in version 7 (or higher) of the Crystal Reports Designer?
    Resolution
    Shared variables, introduced in Crystal Reports version 7, make it easier to pass values from a subreport to the main report. Using shared variables requires two formulas: one to store the value in a shared variable, the other to retrieve the value from the shared variable.
    The most important thing to remember when using shared variables is that Crystal Reports must first evaluate the formula where the value is stored before evaluating the formula that retrieves the shared variable.
    For example if you want to pass a grand total from the subreport to do a calculation in the main report, follow these steps:
    1. In the subreport, create a formula similar to the one below:
    //@SubFormula
    //Stores the grand total of the
    //{Orders.Order Amount} field
    //in a currency variable called 'myTotal'
    WhilePrintingRecords;
    Shared CurrencyVar myTotal := Sum ({Orders.Order Amount})
    2. Place this formula in your subreport.
    3. In the main report, create a formula that declares the same variable name:
    //@MainFormula
    //Returns the value that was stored
    //in the shared currency variable called
    //myTotal in the subreport
    WhilePrintingRecords;
    Shared CurrencyVar myTotal;
    myTotal
    4. Place @MainFormula in a main report section that is beneath the section containing the subreport.
    NOTE:======
    For the shared variable to return the correct value in the main report, you must place @MainFormula in a main report section that is beneath the section containing the subreport. This ensures Crystal Reports evaluates the @SubFormula before @MainFormula.
    One way to do this is to insert a section below the section containing the subreport, and place @MainFormula in this new sub-section:
    · On the 'Format' menu, click 'Section'.
    · On the 'Sections' list, click the section containing the subreport.
    · Click 'Insert' (at top of dialog box). This inserts an additional subsection.
    · Click 'OK' to return to the report, and insert @MainFormula into this new sub-section.
    The next time you preview the report, @MainFormula displays the value from the subreport. In this particular example, that value was the grand total of the {Orders.Order Amount} field.
    ============
    5. Once you have verified that @MainFormula is returning the correct value from the subreport, you can include this formula in other main report formulas, such as:
    //@NewFormula
    //includes data from subreport
    {@MainFormula}+ Sum ({Customer.Last Year's Sales})
    · Place this formula in the same section as @MainFormula, or in a section further down on the report.
    You have now successfully shared data from a subreport with the main report.
    NOTE: =====
    This is not possible with On Demand Subreports in Crystal Reports.

  • After changing a subreport I loose data in the main report.

    Hi All,
    I have a main report that has two parameter fields and two subreports linked to the parameter fields.  The two subreports access the database and work fine separately.  When I add the two subreports to the main report it works fine.  As soon as I make a change to a subreport it works fine standalone.  But as soon as I update the main report (reimport subreport) the subreport no longer returns data to the main report.  To get the report to work after a change to a subreport I have to delete the subreport from main and then add it back in again.
    Does anyone have any suggestions?
    I am using Crystal Reports 10 and I'm totally at my wits end.  I've been working with Crystal for about 5 years and this is the first time I've seen this.  Maybe I'm missing something small but I just can't seem to find the answer.
    Thanks for any help,
    Jim

    Jim:
    I usually edit my subreports from within the main report.  I right click the subreport and then click edit subreport.  This eliminates the need to reimport the subreport.  I've done a lot of work with subreports and this always works for me.
    I hope this is not too late and helps you out.
    Ralph

Maybe you are looking for