SQL or Formula in Crystal 8.5?

Hello Forum Oracles!
I am new to Crystal and SQL. I have had no formal training in any aspect of IT but have a good understanding of certain things. I have been around windows based PC since the early 1990s. I need help in writing a formula or SQL I know not which. This is my problem.
We are a vending company and have men that fill up these machines with stock. I am producing a report to forcast their stock requirments based on the amount of machines they service, new machines in their area and historical usage of stock. I have a parameter where I can enter usage in a period between dates but what i would like is for the report to automaticlly tell me what they have used in the last 42 days. I have used the SQL experssion {fn NOW()}-42 to return a date 42 day pervious but I am now stuck on how to get this in a report. This is as far as my logic and abilities take me:
vw_StockMovement_Usage."amendedAt" BETWEEN {fn NOW()} AND {fn NOW()}-42
Your help will be very much apprecated.
David

Hi David,
You can get rid of the parameter and instead use a record selection formula like this (Report > Selection Formulas > Record):
vw_StockMovement_Usage."amendedAt" >= dateadd("d",-42,currentdate)
Hope this helps!
-Abhilash

Similar Messages

  • Accessing trend line formula in Crystal Report

    I am using Crystal Reports 8.5 and CR2008.  I have a report showing a trend line (specifically the quadratic regression).  I can show the formula that is being used for the report in the chart.  How can I access the regression formula in Crystal Reports?
    Thank you for your help.

    hi James,
    in short you can't...the charting engine is a separate 3rd party dll so what you see there is not necessarily available in the rest of cr in summaries etc.
    in order to do things like this, you either have to do the calcs on your database or using formulas. i've attached an example of linear regression that i did a while ago. change the .txt extension to .rpt after you extract the contents. sorry, there are no instructions on how to do this.
    on the attached sample though it does figure out the regression formula and also extrapolate data, show residuals etc.   there are a couple of other "fits" in a parameter but i never finished those as it made my head hurt
    -jamie

  • Formula in Crystal

    Hi,
    I am trying to use a formula in crystal report. I have a dataset that contains list of customers. I wanna assign different numbers on report to each customer. I dont have any idea how to do it. Any help.
    Thanks

    Hi, 
    That description helps a lot.  What you need to do before we create the PickList is get a list of all the customers into an array and assign them a number.  I'm going to recommend a subreport to generate the array. 
    Create a subreport that will link to your picklist so we can get a DISTINCT list of the customers.  In the subreport create a formula like: 
    WhilePrintingRecords;
    Shared StringVar MyCustomers;
    myCustomers := myCustomers & {table.CustomerName} & ",";
    This should go into the Detail section. 
    In the Report Footer we just need to clean up the string like: 
    WhilePrintingRecords;
    Shared StringVar MyCustomers;
    If Right (MyCustomers, 1) = "," Then
        MyCustomers := MyCustomers [1 to (Length (MyCustomers) - 1)];
    This will remove the trailing comma separator. 
    If  you have the main report grouped by PickList, drop the subreport into the Group Header and link them.  If your report is generating 1 picklist then drop it into the Report Header. 
    Now you can create a formula in the main report like: 
    WhilePrintingRecords;
    Shared StringVar MyCustomers;
    StringVar BoxNo := "";
    NumberVar i;
    i := 1;
    If  {table.CustomerName} In Split (MyCustomers, ",") Then
        For i := 1 to Count (Split (MyCustomers, ",")) Do
            If Split (MyCustomers, ",") <i> =  {table.CustomerName} Then
                BoxNo:= ToText (i, 0, "", "") 
            Else "";
    BoxNo;
    This formula converts the customer list into an array and loop through the array to return the element number as the box number. 
    Good luck,
    Brian

  • How to execute SQL Query from the Crystal report X1

    Dear All,
    I am using crystal report X1. In my application am creating run time MS Access tables and giving table name at run time based on my requirement . From these tables I want to fetch data based on some condition and to display using crystal report X1. I have never used the SQL Queries in the Crystal reports. Please help me out.
    Thanks and Regards,
    Rahaneef T

    Please note;
    This forum is dedicated to all other development-related questions which are not directly addressed by other forums. This includes Business Objects SDKs, products, or technologies which do not fall under BusinessObjects Enterprise, BusinessObjects Edge, Crystal Reports Server, or Crystal Reports (for example Desktop Intelligence SDK, Universe Designer SDK, Portal Integration Kits, Java User Function Libraries, and other third party technologies or development languages).
    This looks more like a Crystal Reports design issue?
    Ludek

  • Last date for an invoice formula for Crystal Reports

    Post Author: jegva
    CA Forum: Crystal Reports
    I sure hope someone can help me write a formula to list only the last dated invoice from our database.  Let me explain, our sales would like a report listing all of our customers showing their last dated invoice.  We use SQL and Crystal Reports 8.5 (yea outdated).  They are interested in showing all our customers and their last invoice/date so they can try to contact those who have not done business for some time. Please help!!!!!!!

    Hi Scott,
    One reason is the older versions introduced a .5 font reduction in the viewers. This was a good thing for some but bad thing for others so I assume what the developers have done is leave the font as is and show those # symbols now to indicate the viewer you are using and font you are using works differently on the OS and the various viewers being used.
    In CR designer it uses the GDI+ to render the data through classic C++ function calls. I .NET it too uses GDI+ but it's the Framework making the calls and the Framework handles screen mapping differently. We've had this issue/functionality limitations since version 9. Various reasons and various work arounds resulted in various outputs.
    Another reason is the C++ viewer built into the Report Designer and the .NET framework handling the fonts work slightly differently when rendering. This has been tracked and few times here by me and in both cases the cause is GDI+ has bugs in it so it's nothing we can do. Post or log your issue with Microsoft, they may be able to fix it. Once they do then if it's still a problem in CR we can fix it depending on what MS does.
    Another work around may be to use a fixed font like Courier or some other font that has a specified character area all characters use, it may make the characters space oddly but as for displaying it's always the same size.
    All I can suggest is they get into a practice of testing their reports in your app before "publishing"
    Thanks again
    Don

  • Unable to get the data from ms sql stored procedures using crystal report 10

    Dear,
    I am using the crystal report 10 and MS SQL 2000. I created stored procedures and after making the connection, i am unbale the data from that procedure. When i run stored procedure on MS SQL server it works fine.
    Please help me.
    Best Regards
    Pankaj
    [email protected]

    Dear,
    I am using the crystal report 10 and MS SQL 2000. I created stored procedures and after making the connection, i am unbale the data from that procedure. When i run stored procedure on MS SQL server it works fine.
    Please help me.
    Best Regards
    Pankaj
    [email protected]

  • Working days formula and Crystal 7 - is it possible?

    Post Author: Tim F
    CA Forum: Formula
    Hi folks,
    Really hope someone can help, I'm struggling with writing a report that needs to show the difference between two dates in working days. I've found the same formula posted here several times but cannot get it to return a logical value in my report. I'm wondering if that might be because I'm using an older version of Crystal? The formula in question is this one:
    //Main formulaWhileReadingRecords;Local DateVar Start := ({PPV_COMPLAINTSEH.DTRECD});   Local DateVar End := ({PPV_COMPLAINTSEH.ACTCMPLTD}); Local NumberVar Weeks; Local NumberVar Days; Local Numbervar Hol;DateVar Array Holidays;
    Weeks:= (Truncate (End - dayofWeek(End) + 1 - (Start - dayofWeek(Start) + 1)) /7 ) * 5;Days := DayOfWeek(End) - DayOfWeek(Start) + 1 + (if DayOfWeek(Start) = 1 then -1 else 0)  + (if DayOfWeek(End) = 7 then -1 else 0);  
    Local NumberVar i;For i := 1 to Count (Holidays)do (if DayOfWeek ( Holidays&#91;i&#93; ) in 2 to 6 and      Holidays&#91;i&#93; in start to end then Hol:=Hol+1 );
    Has anyone come across an alternative way of doing this, or have any ideas why this formula is not working in my report? Any advice would be much appreciated,
    Regards,
    Tim

    Post Author: Charliy
    CA Forum: Formula
    You set up a Running Total.  Drag the filed you want Summed, Select Sum as the operation if that is not the default.
    Just below that you weill see Radio Buttons that say For Every Record, On Change of Group, On Change of Field, Use a Formula, etc - click the one that says Use a Formula.  The Blue Bos to its right will turn Red, click on it, this is where you put your formula: NOT(DATEPART('w',{table.date}) IN &#91;6,7&#93;)
    Save that, then just decide if you want it reset on a Change of Group, or Never (Grand Total).  Give it a name and put it on your report.

  • Vista/Adobe 9/sql image Error in Crystal Report:Failed to Export the Report

    When I try to export my Crystal Report (v2008) from a Vista machine (using Crystal RDC export methods) as a PDF, I get the following error:
    Error in Crystal Report:  Failed to export the report.
    This only happens when a particular subreport (that contains a sql image) prints (based on an input parameter).  We have other subreports (within this same report) that print a sql image just fine.  But, when this subreport prints, the above error appears.
    I can run the same report on an XP machine without error.
    Exportmodeller.dll and crtsv.dll are both installed and registered to the
    C:\Program Files\Common Files\Business Objects\3.0\bin folder
    I have tried opening the report, removing the image, and then adding it back in again to the subreport.
    Still receive the same error.
    Any suggestions?

    >
    Don Williams wrote:
    > RDC is no longer shipped in CR 2008. You are using the embedded designer used within the Visual Studio .NET IDE and is not licensed for distribution.
    >
    > Upgrade to the .NET components and post your question to the .NET forums.
    >
    > Also, those old dll's will not work in CR 2008. Last patches will give you the option to export to Excel in Legacy mode. We built it into our export dll.
    Don,
    Can you please clarify?
    Our VB6 app that uses Crystal XI RDC runtime components.  Our Crystal reports are edited in CR2008 SP1 developer edition (not through the VB.NET embedded report designer).  We have deployed the CRXIRelease 2 runtime components (via the merge module) to our client machines in order to execute the RDC.
    We can print/preview/export to excel, but the pdf creation is failing with this error.
    We are only using the RDC (which we know is no longer supported) because of huge issues with the Crystal for .NET methods we are having with our customers (I have an active case for this issue).  Therefore, we have to rollback our .NET product and revert to the RDC code. 
    Vista is failing to create a PDF for a report developed in the CR2008 SP1 developer edition when using the RDC.
    When you say  "Also, those old dll's will not work in CR 2008. Last patches will give you the option to export to Excel in Legacy mode. We built it into our export dll.", what do you mean by "will not work in CR2008"?
    Thank you

  • Is there a way to Extract all formulas from Crystal Reports files?

    Hi:
    I have about 40 Crystal Reports (.rpt files).  I need to go through each one and look at formulas if a certain variable/value is used since it has currently changed.  It is taking way too long and not to mention inefficent to open each file, look through any place where there could be custom formulas such as when to suppress - etc.  Is there are way to easily exact all custom formulas from all those report into say a Text file so I can do a Search for it?  That would be the easiest way to find what I'm looking for.
    I have Crystal Reports XI.
    Thanks in advance for your help.

    One option is to use a tool such as rptInspector.  See: [http://www.softwareforces.com/Product/ri/pro/3/rptInspector.htm|http://www.softwareforces.com/Product/ri/pro/3/rptInspector.htm]

  • How to set Formulas in crystal reports 2008

    Hi,
    I am generating crystal reports in vb6 using CR 8.5 and vb6 and below is the code snippet for the same
    CrystalReport1.Formulas(0) = "PrintTitle= '" & strMyTitle & "'"
    CrystalReport1.Formulas(1) = "FromDate= '" & MskFromDate.Text & "'"
    CrystalReport1.Formulas(2) = "ToDate= '" & MskToDate.Text & "'"
    Please let me know how the same functionality can be achieved in VB.Net using Crsytal reports 2008
    Any code snippet would be of great Help.
    Thanks in Adnvance.
    Ramnath

    Something like this:
    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared
    Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim Report As New CrystalReport1()
    Dim FormulaFields As FormulaFieldDefinitions
    Dim FormulaField As FormulaFieldDefinition
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    FormulaFields = Report.DataDefinition.FormulaFields
    FormulaField = FormulaFields.Item(0)
    FormulaField.Text = "[formula text]"
    CrystalReportViewer1.ReportSource = Report
    End Sub
    Also, see the Developer help file:
    http://help.sap.com/businessobject/product_guides/boexir31/en/crsdk_net_dg_12_en.chm
    API reference:
    http://help.sap.com/businessobject/product_guides/boexir31/en/crsdk_net_apiRef_12_en.chm
    and [Crystal Reports for Visual Studio 2005 Walkthroughs|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/2081b4d9-6864-2b10-f49d-918baefc7a23]
    And don't forget to use the search box at the top right of this page before posting to the forums...
    Ludek
    Follow us on Twitter http://twitter.com/SAPCRNetSup
    Edited by: Ludek Uher on Jul 26, 2010 8:57 AM

  • Creating a SQL Expression Formula

    Post Author: edt11
    CA Forum: Formula
    I need to due a lookup on name(stored in a different table).  I want to display the name result on the report.
    I have tried using the following SQL:
    SELECT distinct(a.short_name) FROM FUND A, FUND_EXTERNAL BWHERE A.FUND_NUMBER = B.CUSTODIAN_KEY
    And I keep receiving an ORA-00936 error (Missing Expression).  If there is a way to retrieve this info in a normal formula that would be great as well.  But the SQL above gives me the results I am looking for so I didn't exhaust all solutions in the Formula Workshop.
    Thanks

    Post Author: edt11
    CA Forum: Formula
    I need to due a lookup on name(stored in a different table).  I want to display the name result on the report.
    I have tried using the following SQL:
    SELECT distinct(a.short_name) FROM FUND A, FUND_EXTERNAL BWHERE A.FUND_NUMBER = B.CUSTODIAN_KEY
    And I keep receiving an ORA-00936 error (Missing Expression).  If there is a way to retrieve this info in a normal formula that would be great as well.  But the SQL above gives me the results I am looking for so I didn't exhaust all solutions in the Formula Workshop.
    Thanks

  • Programmatically create objects and formulas in Crystal Reports XI Developer edition?

    <p>Is it possible to programatically/dynamically create a text, line, formula field object, etc. in Crystal XI Developer edition?  I have been programming with the Crystal .Net reports component that came with VS 2005 for the past 6 months and know for a fact you can&#39;t programmatically create those objects although you can programmatically control their properties.  My intention is to create a dynamic report that can be reused extensively.  My current work-around for this was to create a generic report with about 40 formula field objects which draws data from 40 corresponding formula fields that I can programmatically set it&#39;s formula thus imitating a report field.  I want to update to the developer edition because I heard with this edition we can programmatically create and manipulate these objects but I found no reference or examples anywhere that proves we can do this?  Does anyone know for a fact or point me to the right place to look for documentation?  TIA</p>

    Hi,
    How can I programmatically refresh list of values status on CR server XI R2?
    Currently, after I modified the data source in the data connection, some of the LOVs in the report prompt window became empty when I tried to generate the report. I have to use Business View Manager to log onto the Crystal reports server XI R2, find and double click the list of values object to bring up the Edit LOV window, and then click on "Refresh Status" button to make the LOV available in the report prompt window.
    What SDK should I use to create a simple application (preferable a desktop application) to find all LOV objects on CR server XI R2 and to refresh their status? That is an application similar to the "Refresh Status" function in Business View Manager.
    I found Report Engine SDK has the Lov.Refresh function to refresh LOV. On the other hand, Report Engine SDK seems to be for BusinessObjects Enterprise, not for Crystal Reports Server. Can this or other function achieve what I want, i.e. to refresh list of values status on CR server XI R2? If yes, can I use it to develop a self-contained desktop application instead of a web application? I only need to run this application after I modify the data source in the data connection, so I prefer not need to deploy it as a web service.
    Thanks for your help.
    C.T.

  • Dynamic SQL in Formula Column in OracleReports6i

    Following code is in formula column of my report. passing dynamic sql str1(actullay, this string comes from after parameter trigger form) into SQL and executing thru DBMS_SQL.PARSE function. it's failed with 'Fatal PL/SQL error occured' ...
    Coupld any one help me on this...
    function CF_1FORMULA0006 return Number is
    Credits1 NUMBER(10,2);
    str1 VARCHAR2(50) := 'AND b.PROGRAMID = 2 ';
    c1 INTEGER := dbms_sql.open_cursor;
    c2 INTEGER;
    begin
    begin
    dbms_sql.parse(c1,
    'SELECT NVL(SUM(a.AMOUNT),0) INTO Credits1' &#0124; &#0124;
    'FROM SPONSOR_TRAN_DATA a, SPONSOR b ' &#0124; &#0124;
    ' WHERE ' &#0124; &#0124;
    ' a.TRANTYPE = 41 ' &#0124; &#0124;
    ' AND a.SPONSORID = b.SPONSORID ' &#0124; &#0124;
    str1 &#0124; &#0124;
    'AND a.amount > 0 ' &#0124; &#0124;
    'AND a.timestamp >= :reportdate ' &#0124; &#0124;
    'AND a.timestamp < :reportdate + 1' ,2);
    c2 := dbms_sql.execute(c1);
    exception
    when no_data_found then
    Credits1 := 0;
    end;
    return Credits1;
    end;
    Thanks in advance......

    It looks like forms are not supporting text functions like FR yet, I gave it a try <<MemberName("<Formname>","<POV DIM Name>)>> in the formula header area and it didn't like it. It is just displaying what ever I typed in there.

  • Problem accessing Sql server Procedure from Crystal with JDBC driver

    I have some Crystal reports using SQL Server procedures, most of them are working very well; however, I have 2 that have problems accessing sql server procedures. These reports are working using OLE DB connection without problem, but when I try to relocate the connection to JDBC Crystal generates an error like that the procedure not return records.
    The procedure is working with other products including OLE DB connections from crystal.
    What can I do?
    Thanks in Advance,
    JaimeC

    I am using:
    Crystal report 11 - 11.0.0.1282 and Crystal 2008 = 12.0.0.683
    SQL Server 2005 -  Microsoft SQL Server Management Studio Express     9.00.4035.00
    Windows XP
    I have discovered that the procedures create and work  temporary tables. In other cases when is working ok, the procedures have not working temporary tables.
    Thanks,
    Jaime Carrillo

  • Formula in Crystal Report

    hi
    can anyone tell what is the error in this formula
    if  not isnull {GetDataTable.MARK_PRICE_RATE} then
    (({GetDataTable.mark_price_rate} * {GetDataTable.BILL_DET_COUNT})  -  {GetDataTable.JARIMEH } )
    it is displaying the error like this
    The keyword 'then' missing

    Hi,
    Please post your question at crystal reports forum below for a better assistance on this, this is C# code related forum:
    https://scn.sap.com/community/crystal-reports
    Regards,
    Fouad
    Fouad Roumieh

Maybe you are looking for