MAX function possible in HFM?

Hi
Is there some function in HFM which can return maximum of set of values.
for a report, i need to find the max of a values against C2 -- but i could not find any HFM function to that effect.
Has anyone tried and done it ?

If you want to find the MAX value you have to write a calculation script for the same as HFM does not have any predefined MAX function. But if this is just for the purpose of reporting then you can use the functions in the reporting tool for the same.
Varun
Edited by: Varun Kaushal on Mar 18, 2010 9:49 AM

Similar Messages

  • How to Avoid Errors in Max Function When Data Contains Blank Cells

    I have a column with duration values. However, it also contains some blank cells. These "blank cells" have formulas in them, but as the cells they reference too are blank the formula doesn't produce a result.>/p>
    I want to get the max value from this column. When I simply do =MAX(column-name) I get an error, presumably because some of the cells are blank. This table is going to be highly dynamic, so I don't want to limit the range of the MAX() function to only those cells with values.
    So does anyone know a solution for this, please? If I was some how able to create a formula which returned the range of cells with actual values, then I could use that in the MAX() function. Or, if I could somehow tell the MAX() function to ignore blank cells, but I'm not sure either of these are possible.
    Thanks,
    Nic

    I don't see a problem with "blank" (null string) cells mixed with duration cells.  MAX works fine with this mix of cells. But if the "blank" cells are numbers, not text, that gives an error.
    A formula always produces a result. A formula cannot result in a blank cell. The closest you can get to "blank" is a null string (the result of two quotes next to each other with nothing between them) . So the question is, what is the result that you are calling "blank"?

  • Bug? using MAX() function on char(1) column returns something larger

    details:
    -- we have a complex nested query, where we are essentially returning the max() value into a variable
    -- the max() function is being used on a char(1) column
    -- where MAX() is part of an inner select, we have started getting
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    errors.
    SELECT MAX(X) INTO var FROM ... works in 9i and 10g
    SELECT X INTO var FROM (SELECT MAX(X) X FROM ... worked in 9i, does not work in 10g!
    -- We never had problems with the code until upgrading to 10g release 2.
    -- the Solution is to cast the final value with TO_CHAR(). The cast MUST be done at the outer most point of the select:
    SELECT TO_CHAR(X) INTO var FROM (SELECT MAX(X) X FROM ... works
    SELECT X INTO var FROM (SELECT TO_CHAR(MAX(X)) X FROM ... causes an error!
    The following script demonstrates the issue, and includes the solution:
    * October 3, 2006
    * Possible SQL bug introduced with Oracle 10G
    * Natalie Gray DBA/Developer, Environment Canada
    * Description:
    * Have discovered a problem with using the MAX() function
    * on columns of type char(1)
    * only an issue when used in an inner select
    * solution (see test 4)
    CREATE TABLE SQL_BUG_TEST
    X NUMBER,
    Y NUMBER,
    Z CHAR(1)
    INSERT INTO SQL_BUG_TEST (X, Y, Z)
    VALUES (1,1,'A');
    INSERT INTO SQL_BUG_TEST (X, Y, Z)
    VALUES (1,1,'B');
    INSERT INTO SQL_BUG_TEST (X, Y, Z)
    VALUES (1,2,'C');
    INSERT INTO SQL_BUG_TEST (X, Y, Z)
    VALUES (1,2,'D');
    DECLARE
    TYPE REC IS RECORD (
          x SQL_BUG_TEST.X%TYPE,
          y SQL_BUG_TEST.Y%TYPE,
          z SQL_BUG_TEST.Z%TYPE
    v_rec REC;
    BEGIN
          -- DISPLAY THE TABLE DATA
          BEGIN
                 DBMS_OUTPUT.PUT_LINE('TABLE DATA:');
                DBMS_OUTPUT.PUT_LINE('');
                 DBMS_OUTPUT.PUT_LINE('SELECT * FROM SQL_BUG_TEST ORDER BY X,Y,Z;');
                 FOR crs IN (SELECT *
                                     FROM SQL_BUG_TEST
                               ORDER BY X,Y,Z) LOOP
                    DBMS_OUTPUT.PUT_LINE(':'||crs.X||':'||crs.Y||':'||crs.Z);
                END LOOP;
          EXCEPTION WHEN OTHERS THEN
                 DBMS_OUTPUT.PUT_LINE(SQLERRM);       
          END;
          -- TEST 1
          -- returning result from MAX into a variable when the MAX is in the outer most select
          -- does not cause an error
          BEGIN
                 DBMS_OUTPUT.PUT_LINE('*****************************************************');
                 DBMS_OUTPUT.PUT_LINE('TEST 1');
                DBMS_OUTPUT.PUT_LINE('');
                 DBMS_OUTPUT.PUT_LINE('SELECT X, Y, MAX(Z) Z');
                DBMS_OUTPUT.PUT_LINE('FROM SQL_BUG_TEST');
                DBMS_OUTPUT.PUT_LINE('GROUP BY X,Y');
                FOR crs IN (SELECT X, Y, MAX(Z) Z
                                     FROM SQL_BUG_TEST
                               GROUP BY X, Y
                               ORDER BY X,Y,Z) LOOP
                     DBMS_OUTPUT.PUT_LINE(':'||crs.X||':'||crs.Y||':'||crs.Z);
                END LOOP;
          EXCEPTION WHEN OTHERS THEN
               DBMS_OUTPUT.PUT_LINE(SQLERRM);
          END;
          -- TEST 2
          -- returning MAX() from an inner select to an outer select and then into a variable
          -- causes an error
          BEGIN
                 DBMS_OUTPUT.PUT_LINE('*****************************************************');
                 DBMS_OUTPUT.PUT_LINE('TEST 2');
                DBMS_OUTPUT.PUT_LINE('THIS DID NOT CAUSE AN ERROR WITH ORACLE 9i');
                DBMS_OUTPUT.PUT_LINE('');
                 DBMS_OUTPUT.PUT_LINE('SELECT * INTO v_rec');
                DBMS_OUTPUT.PUT_LINE('FROM');
                DBMS_OUTPUT.PUT_LINE('(SELECT X, Y, MAX(Z) Z');
                DBMS_OUTPUT.PUT_LINE('FROM SQL_BUG_TEST');
                DBMS_OUTPUT.PUT_LINE('GROUP BY X,Y)');
                DBMS_OUTPUT.PUT_LINE('WHERE Y = 1');
                SELECT * INTO v_rec
                FROM
                (SELECT X, Y, MAX(Z) Z
                 FROM SQL_BUG_TEST
                 GROUP BY X, Y)
                WHERE Y = 1;
                DBMS_OUTPUT.PUT_LINE(':'||v_rec.X||':'||v_rec.Y||':'||v_rec.Z);
          EXCEPTION WHEN OTHERS THEN
               DBMS_OUTPUT.PUT_LINE(SQLERRM);
          END;
          -- TEST 3
          -- casting the result from MAX to char before returning to the outer select
          -- still causes an error
          BEGIN
                 DBMS_OUTPUT.PUT_LINE('*****************************************************');
                 DBMS_OUTPUT.PUT_LINE('TEST 3');
                DBMS_OUTPUT.PUT_LINE('');
                 DBMS_OUTPUT.PUT_LINE('SELECT * INTO v_rec');
                DBMS_OUTPUT.PUT_LINE('FROM');
                DBMS_OUTPUT.PUT_LINE('(SELECT X, Y, to_char(MAX(Z)) Z');
                DBMS_OUTPUT.PUT_LINE('FROM SQL_BUG_TEST');
                DBMS_OUTPUT.PUT_LINE('GROUP BY X,Y)');
                DBMS_OUTPUT.PUT_LINE('WHERE Y = 1');
                SELECT * INTO v_rec
                FROM
                (SELECT X, Y, to_char(MAX(Z)) Z
                 FROM SQL_BUG_TEST
                 GROUP BY X, Y)
                WHERE Y = 1;
                DBMS_OUTPUT.PUT_LINE(':'||v_rec.X||':'||v_rec.Y||':'||v_rec.Z);
          EXCEPTION WHEN OTHERS THEN
               DBMS_OUTPUT.PUT_LINE(SQLERRM);
          END;
          -- TEST 4 - SOLUTION
          -- the return value of MAX must be cast with to_char at the point where it is assigned to
          -- variable (outer most select)
          BEGIN
                 DBMS_OUTPUT.PUT_LINE('*****************************************************');
                 DBMS_OUTPUT.PUT_LINE('TEST 4 SOLUTION');
                DBMS_OUTPUT.PUT_LINE('');
                 DBMS_OUTPUT.PUT_LINE('SELECT X, Y, TO_CHAR(Z) Z INTO v_rec');
                DBMS_OUTPUT.PUT_LINE('FROM');
                DBMS_OUTPUT.PUT_LINE('(SELECT X, Y, MAX(Z) Z');
                DBMS_OUTPUT.PUT_LINE('FROM SQL_BUG_TEST');
                DBMS_OUTPUT.PUT_LINE('GROUP BY X,Y)');
                DBMS_OUTPUT.PUT_LINE('WHERE Y = 1');
                SELECT X, Y, TO_CHAR(Z) Z INTO v_rec
                FROM
                (SELECT X, Y, MAX(Z) Z
                 FROM SQL_BUG_TEST
                 GROUP BY X, Y)
                WHERE Y = 1;
                DBMS_OUTPUT.PUT_LINE(':'||v_rec.X||':'||v_rec.Y||':'||v_rec.Z);
          EXCEPTION WHEN OTHERS THEN
               DBMS_OUTPUT.PUT_LINE(SQLERRM);
          END;
    END;

    I certainly looks like a bug, but you should raise an iTAR on Metalink since Oracle does not monitor this forum.
    I was able to replicate your results on my 10.2.0.1 database.
    There is an easier workaround than yours. Try
    ALTER TABLE sql_bug_test MODIFY (z VARCHAR2(1));That seems to eliminate the problem on my instance.
    John

  • MAX Function not returning MAX

    I have a query that is pulling in EDI 214 status codes, and want to pull in the last received status for status type "AG". To do this, I'm using the MAX function on the INSERT_DATE field of the status code AG, but the query keeps returning both AG status codes. I've tried this in a single query (Query 1) but it did not work so I also attempted it in a much smaller query to be used as a subquery, but that still did not work. Can anyone identify what the issue is with what I'm attempting to do?
    Query 1 (All Inclusive):
    SELECT BS.SHIPMENT_GID AS BUY_SHIPMENT_GID,
    AGSS.EVENTDATE AS AG_EVENT,
    D1SS.EVENTDATE AS D1_EVENT,
    BS.START_TIME AS BUY_START_TIME,
    AGSS.STATUS_CODE_GID AS AG,
    D1SS.STATUS_CODE_GID AS D1,
    BS.DOMAIN_NAME AS BUY_DOMAIN,
    MAX(AGSS.INSERT_DATE) AS AG_INSERT_DATE,
    MAX(D1SS.INSERT_DATE) AS D1_INSERT_DATE,
    BS.START_TIME,
    BS.DOMAIN_NAME,
    SHIPSTAT.STATUS_VALUE_GID
    FROM V_ROD_SHIPMENT BS
    INNER JOIN V_ROD_SS_STATUS_HISTORY AGSH
    ON (BS.SHIPMENT_GID = AGSH.SHIPMENT_GID)
    INNER JOIN V_ROD_IE_SHIPMENTSTATUS AGSS
    ON (AGSH.I_TRANSACTION_NO = AGSS.I_TRANSACTION_NO)
    INNER JOIN V_ROD_SS_STATUS_HISTORY D1SH
    ON (BS.SHIPMENT_GID = D1SH.SHIPMENT_GID)
    INNER JOIN V_ROD_SHIPMENT_STATUS SHIPSTAT
    ON (BS.SHIPMENT_GID = SHIPSTAT.SHIPMENT_GID)
    INNER JOIN V_ROD_IE_SHIPMENTSTATUS D1SS
    ON D1SH.I_TRANSACTION_NO = D1SS.I_TRANSACTION_NO
    WHERE BS.START_TIME > '18/MAY/12'
    AND BS.DOMAIN_NAME = 'UPS/CP/HDMB'
    AND AGSS.STATUS_CODE_GID = 'AG'
    AND D1SS.STATUS_CODE_GID = 'D1'
    AND (SHIPSTAT.STATUS_VALUE_GID = BS.DOMAIN_NAME
    || '.SECURE RESOURCES_ACCEPTED'
    OR SHIPSTAT.STATUS_VALUE_GID = BS.DOMAIN_NAME
    || '.SECURE RESOURCES_PICKUP NOTIFICATION')
    GROUP BY BS.SHIPMENT_GID,
    AGSS.EVENTDATE,
    D1SS.EVENTDATE,
    BS.START_TIME,
    AGSS.STATUS_CODE_GID,
    D1SS.STATUS_CODE_GID,
    BS.DOMAIN_NAME,
    SHIPSTAT.STATUS_VALUE_GID
    Query 2 (to be used as a sub-query if I cannot pull MAX insert date in previous query):
    SELECT DISTINCT BS.SHIPMENT_GID AS BUY_SHIPMENT_GID,
    AGSS.EVENTDATE AS AG_EVENT,
    AGSS.STATUS_CODE_GID AS AG,
    MAX(AGSS.INSERT_DATE) AS AG_INSERT_DATE
    FROM V_ROD_SHIPMENT BS
    INNER JOIN V_ROD_SS_STATUS_HISTORY AGSH
    ON (BS.SHIPMENT_GID = AGSH.SHIPMENT_GID)
    INNER JOIN V_ROD_IE_SHIPMENTSTATUS AGSS
    ON (AGSH.I_TRANSACTION_NO = AGSS.I_TRANSACTION_NO)
    WHERE AGSS.STATUS_CODE_GID = 'AG'
    AND BS.SHIPMENT_GID = 'UPS/CP/HDMB.HDM-1000203768'
    GROUP BY BS.SHIPMENT_GID,
    AGSS.EVENTDATE,
    AGSS.STATUS_CODE_GID
    Results of query 2 (similar issue as query 1, query doesn't return MAX insert date):
    BUY_SHIPMENT_GID     AG_EVENT     AG     AG_INSERT_DATE
    UPS/CP/HDMB.HDM-1000203768     5/25/2012 6:00:00 PM     AG     5/21/2012 3:10:36 PM
    UPS/CP/HDMB.HDM-1000203768     6/1/2012 5:00:00 PM     AG     5/20/2012 2:36:18 PM
    I appreciate any help.
    Thanks,
    -Adam

    Hi, Adam,
    Welcome to the forum!
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    Simplify the problem as much as possible. Remove all tables and columns that play no role in this problem.
    If you can show what the problem is using commonly available tables (such as those in the scott schem) then you don't have to psot any sample data; just the results and the explanation.
    Always say which version of Oracle you're using.
    See the forum FAQ {message:id=9360002}
    MAX (insert_date) returns the latest insert_date. I think, in this problem, you don't really want the latest insert_date; you want the status code that's related to the last insert_date. One way to get that is the aggregate FIRST (or LAST) function.
    Consider this query, using the scott.emp table:
    SELECT       ename
    ,       hiredate
    FROM       scott.emp
    ORDER BY  hiredate
    ,            ename
    ;Output:
    ENAME      HIREDATE
    SMITH      17-Dec-1980
    ALLEN      20-Feb-1981
    WARD       22-Feb-1981
    JONES      02-Apr-1981
    BLAKE      01-May-1981
    CLARK      09-Jun-1981
    TURNER     08-Sep-1981
    MARTIN     28-Sep-1981
    KING       17-Nov-1981
    FORD       03-Dec-1981
    JAMES      03-Dec-1981
    MILLER     23-Jan-1982
    SCOTT      19-Apr-1987
    ADAMS      23-May-1987Say we're only interested in seeing the last hiredate, and the name of the person hired on that date:
    LAST_ENAME LAST_HIREDA
    ADAMS      23-May-1987Here's how to get those results using the aggregate LAST function:
    SELECT       MIN (ename) KEEP (DENSE_RANK LAST ORDER BY hiredate) AS last_ename
    ,       MAX (hiredate)                                              AS last_hiredate
    FROM       scott.emp
    ;What if there's a tie for the latest hiredate? For example, say we're only looking at people hired before 1982. In that case, the latest hiredate is December 3, 1981, and there happen to be two people hired on that date. This query
    SELECT       MIN (ename) KEEP (DENSE_RANK LAST ORDER BY hiredate) AS last_ename
    ,       MAX (hiredate)                                              AS last_hiredate
    FROM       scott.emp
    WHERE         hiredate     < DATE '1982-01-01'
    ;produces only 1 row of output:
    LAST_ENAME LAST_HIREDA
    FORD       03-Dec-1981Why did it show FORD rather than JAMES? Because of the MIN function. When there happens to be a tie for the latest hiredate, MIN says to return the first ename (in normal sort order) of the rows that have that hiredate.
    FIRST and LAST work with GROUP BY, too.
    In the example above, we were only looking at one column related to the latest hiredate. If we neede to see several columns, it would be simpler to use the analytic ROW_NUMBER function:
    WITH     got_r_num     AS
         SELECT  emp.*
         ,     ROW_NUMBER () OVER ( ORDER BY  hiredate  DESC
                                   ,            ename
                           ) AS r_num
         FROM    scott.emp
         WHERE     hiredate     < DATE '1982-01-01'
    SELECT     *
    FROM     got_r_num
    WHERE     r_num     = 1
    I hope this answers your question.
    If not, post a more complete explanation of what you want to do. if you have to use your own tables, then post CREATE TABLE and INSERT statements for a little sample data. Post the results you want from that data, and explain how you get those results from that data.

  • Max function on a date field

    Hi,
    I would like to know if it's possible to do a Max function between two dates ?
    For instance I would like to do:
    Date Y = Max (created date + 4 days) and (Date X + 3 days)
    Thanks for your help,

    Thank you Dinesh for your fast reply.
    My request refer to a field management/WF.. So as you mentionned it's not possible in a standard way.
    But what kind of "other conditional statement" are you talking about?
    Regards,
    Vincent

  • XPath max function

    Hi all,
    I'm a beginner working with XPath expressions.
    I have a xml document 'test.xml' with the following contents.
    <?xml version="1.0" encoding="UTF-8"?>
    <ICRI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.orswegimoarmada.es/ORSWE/ICRI
    http://www.orswegimoarmada.es/ORSWE/XSD/ICRI/ICRI.xsd"
    xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI">
    <ID>ICRI.Prueba.DocPrueba1.2006.11.15-09.19.01</ID>
    <NombreRecurso>DocPrueba1</NombreRecurso>
    <TipoRecurso>Documento Técnico</TipoRecurso>
    <Descripcion>Documento de ejemplo.</Descripcion>
    <ExtensionRecurso/>
    <VersionRecurso>1.0</VersionRecurso>
    <Estado>En Proceso</Estado>
    <NivelSeguridad>NATO UNCLASSIFIED</NivelSeguridad>
    <Entornos/>
    <PalabrasClave/>
    <Sinonimos/>
    <Modificaciones>
    <Modificacion>
    <Usuario>demoadminpro</Usuario>
    <FechaHora>2006.11.15-09.19.01</FechaHora>
    <Secuencia>1</Secuencia>
    <EnlaceRecurso>/ORSWE/Proyectos/Prueba/Documento Técnico/DocPrueba1.2006.11.15-09.19.01.xml</EnlaceRecurso>
    </Modificacion>
    <Modificacion>
    <Usuario>demoadminpro</Usuario>
    <FechaHora>2006.11.15-09.20.01</FechaHora>
    <Secuencia>2</Secuencia>
    <EnlaceRecurso>/ORSWE/Proyectos/Prueba/Documento Técnico/DocPrueba1.2006.11.15-09.20.01.xml</EnlaceRecurso>
    </Modificacion>
    <Modificacion>
    <Usuario>demoadminpro</Usuario>
    <FechaHora>2006.11.15-09.21.01</FechaHora>
    <Secuencia>3</Secuencia>
    <EnlaceRecurso>/ORSWE/Proyectos/Prueba/Documento Técnico/DocPrueba1.2006.11.15-09.21.01.xml</EnlaceRecurso>
    </Modificacion>
    </Modificaciones>
    </ICRI>
    I use the code to obtain information about xml.
    SELECT extractValue(value(d), '/ICRI/NombreRecurso', 'xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI"') NOMBRERECURSO,
           extractValue(value(d), '/ICRI/TipoRecurso', 'xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI"') TIPORECURSO,
            extractValue(value(d), '/ICRI/VersionRecurso', 'xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI"') VERSIONRECURSO,
            extractValue(value(d), '/ICRI/Descripcion', 'xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI"') DESCRIPCION,
            extractValue(value(d), '/ICRI/Modificaciones/Modificacion/Secuencia', 'xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI"') SECUENCIA
    FROM RESOURCE_VIEW r, table(xmlsequence(extract(r.res, '/r:Resource/r:Contents/i:ICRI', 'xmlns:r="http://xmlns.oracle.com/xdb/XDBResource.xsd" xmlns:i="http://www.orswegimoarmada.es/ORSWE/ICRI"'))) d
    WHERE r.any_path='test.xml'But the element Secuencia has several values and I only need to obtain the max of this values. I think, XPath max function can resolve this issue, but I don't know how do I do this?. Is it possible?
    Thanks in advance,
    David.

    Well, I am desperate :-(((
    I am trying to extend the early query, now, r.any_path must be obtained from another table that it is another registered schema also.
    The folowing is a piece of this query:
    SELECT
    extractValue(value(di), '/ICRI/NombreRecurso', 'xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI"') NOMBRERECURSO,
    extractValue(value(di), '/ICRI/TipoRecurso', 'xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI"') TIPORECURSO,
    extractValue(value(di), '/ICRI/VersionRecurso', 'xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI"') VERSIONRECURSO,
    extractValue(value(di), '/ICRI/Descripcion', 'xmlns="http://www.orswegimoarmada.es/ORSWE/ICRI"') DESCRIPCION
    FROM RESOURCE_VIEW r,
         table(xmlsequence(extract(r.res, '/r:Resource/r:Contents/i:ICRI', 'xmlns:r="http://xmlns.oracle.com/xdb/XDBResource.xsd" xmlns:i="http://www.orswegimoarmada.es/ORSWE/ICRI"'))) di
    WHERE
        r.any_path IN 
        (select extractValue(value(t), '/InfoEntradaGeneral/EnlaceICRI', 'xmlns="http://www.orswegimoarmada.es/ORSWE/PlantillaProyecto')
         FROM PLANTILLAPROYECTO p, table(xmlsequence(extract(p.object_value, '/PlantillaProyecto/Proceso/Pasos/Paso[@IdPaso="0"]/Actividades/Actividad[@IdActividad="1"]/EntradasActividad/EntradasGenerales/InfoEntradaGeneral'))) t
         WHERE existsNode(p.object_value, '/PlantillaProyecto/DetallesProyecto[NombreProyecto="Prueba"]')=1);Now, Oracle only shows me a register when the query must be three.
    The query
    select extractValue(value(t), '/InfoEntradaGeneral/EnlaceICRI', 'xmlns="http://www.orswegimoarmada.es/ORSWE/PlantillaProyecto')
    FROM PLANTILLAPROYECTO p, table(xmlsequence(extract(p.object_value, '/PlantillaProyecto/Proceso/Pasos/Paso[@IdPaso="0"]/Actividades/Actividad[@IdActividad="1"]/EntradasActividad/EntradasGenerales/InfoEntradaGeneral'))) t
    WHERE existsNode(p.object_value, '/PlantillaProyecto/DetallesProyecto[NombreProyecto="Prueba"]')=1);returns several values, for instance:
    1. test.xml
    2. test1.xml
    3. test2.xml
    Why does not it work?. I suppose that the query is correct.
    I try the same with relational tables and it works fine.
    Query SELECT B.COLUMN2 FROM B WHERE B.COLUMN1 IN (SELECT COLUMN1 FROM A returns several values from A and shows the right values from B.
    Please, Could someone to help me?
    Thanks in advance,
    David.

  • AdvancedDataGrid Summary Row Max Function

    I am trying to mix summary function within an advanced data grid.   I'm trying to use the SUM function at the highest grouping level (Southwest).  And a MAX function at the sub regional level (Arizona, Central California, etc).    I want the SUM function at the Southwest level to add the results of the MAX functions from the sub regional level.   Is this possible?

    You can do something like this in order to get SUM function
    <!--  The grid -->
        <mx:AdvancedDataGrid  id="adg"
                width="100%" height="100%">
            <!-- Define grouping in dataProvider  -->
            <mx:dataProvider>
                <!-- Convert flat data to group  -->
                <mx:GroupingCollection  id="gc"
                        source="{svc.getOrders.lastResult}">
                    <mx:Grouping>
                        <!-- First group by customer -->
                        <mx:GroupingField name="CUSTOMER">
                            <!-- Calculate total per customer  -->
                            <mx:SummaryRow summaryPlacement="group">
                                <mx:fields>
                                    <mx:SummaryField dataField="PRICE"
                                                    operation="SUM"
                                                    label="Total"/>
                                </mx:fields>
                            </mx:SummaryRow>
                        </mx:GroupingField>
                        <!-- Then group by orderid -->
                        <mx:GroupingField name="ORDERID">
                            <!-- Calculate total per orderid  -->
                            <mx:SummaryRow summaryPlacement="group">
                                <mx:fields>
                                    <mx:SummaryField dataField="PRICE"
                                                    operation="SUM"
                                                    label="Total"/>
                                </mx:fields>
                            </mx:SummaryRow>
                        </mx:GroupingField>
                    </mx:Grouping>
                </mx:GroupingCollection>
            </mx:dataProvider>
            <!-- The grid columns-->
            <mx:columns>
                <!-- Empty colume for tree -->
                <mx:AdvancedDataGridColumn />
                <!-- Query columns -->
                <mx:AdvancedDataGridColumn  dataField="CUSTOMER"
                    headerText="Customer" />
                <mx:AdvancedDataGridColumn  dataField="ORDERID"
                    headerText="Order"/>
                <mx:AdvancedDataGridColumn  dataField="ARTNAME"
                    headerText="Item" />
                <mx:AdvancedDataGridColumn  dataField="PRICE"
                    headerText="Price" textAlign="right" />
                <!-- Column for calculated totals  -->
                <mx:AdvancedDataGridColumn  dataField="Total"
                    headerText="Total" textAlign="right" />
            </mx:columns>
        </mx:AdvancedDataGrid>

  • MAX function

    Hi Everyone,
    Am aware of the following flavors of MAX function
    1) choose MAX from the folders/fields list (selected items tab)
    2) create calculation using: MAX keep dense
    3) create calculation using: MAX analytic function
    questions, pls:
    ===========
    a) with MAX regular, MAX keep dense, MAX - analytic function
    is it necessary to sort it using tools/sort - choose fields to sort by?
    or does the data get sorted due to the ORDER BY clause in MAX used in a calculation
    b) how to understand the diff. bet. MAX keep dense and MAX - analytic function
    1) i understand that analytic functions are applied after detail row processing
    does MAX keep dense calculation happen during detail row processing?
    2) how did you know to advise when to use MAX keep dense, and when to use MAX - analytic function?
    tx for your ideas and assistance, sandra

    Hi,
    a) with MAX regular, MAX keep dense, MAX - analytic function is it necessary to sort it using tools/sort - choose fields to sort by? or does the data get sorted due to the ORDER BY clause in MAX used in a calculationIt is only necessary to use a sort if you want to have the rows returned in a specific order. The order by in the max calculation defines the maximum within the group or window. It may affect the order the rows are returned, but if it does this is not guaranteed and you should use a sort on the main query.
    b) how to understand the diff. bet. MAX keep dense and MAX - analytic function
    1) i understand that analytic functions are applied after detail row processing does MAX keep dense calculation happen during detail row processing?Yes
    2) how did you know to advise when to use MAX keep dense, and when to use MAX - analytic function?In general, if you want the result on a single row, so you have one row for each group then you should use the aggregate max. If you want to use the same max on all the rows in the window (defined by the partition) then use the analytic max.
    Rod West

  • Using max function in PL/SQL

    VERY URGENT...
    Am new to oracle...
    I've written a package that display gif images in form of histogram/bar chart. using html,
    I need to use max function to display values proportionately.
    please help. i need to complete this assignment by 2/9/00 by 10.00 am at the latest. I've half written a function but I don't know if there's a simpler way fo doing this. html enabled

    First of all Thanks to all gentlemen who replied ..many thanks ...
    Tried the ROW_NUMBER() option but still it is taking time...have given output for the query and tkprof results as well. Even when it doesn't fetch any record ( this is a valid cased because the input header id doesn't have any workflow request submitted & hence no entry in the wf_items table)..then also see the time it has taken.
    Looked at the RANK & DENSE_RANK options which were suggested..but it is still taking time..
    Any further suggestions or ideas as to how this could be resolved..
    SELECT 'Y', 'Y', ITEM_KEY
    FROM
    ( SELECT ITEM_KEY, ROW_NUMBER() OVER(ORDER BY BEGIN_DATE DESC) RN FROM
    WF_ITEMS WHERE ITEM_TYPE = 'xxxxzzzz' AND ROOT_ACTIVITY = 'START_REQUESTS'
    AND SUBSTR(ITEM_KEY,1,INSTR(ITEM_KEY,'-') - 1) = :B1
    ) T WHERE RN <= 1
    call count cpu elapsed disk query current rows
    Parse 0 0.00 0.00 0 0 0 0
    Execute 1 0.00 1.57 0 0 0 0
    Fetch 1 8700.00 544968.73 8180 8185 0 0
    total 2 8700.00 544970.30 8180 8185 0 0
    many thanks

  • Regarding MAX() function

    Hi,
    I am having table A. I have few records in the table A. Database version : 9.2
    ID name deleted
    2 XYZ N
    3 ABD N
    4 GJK N
    5 GJK N
    6 HGY N
    7 YJG N
    8 PIN N
    9 BMF N
    10 OLG N
    I used the following query...
    SELECT MAX(ID) FROM A WHERE DELETED='N';
    It was worked fine until now....
    Now i used the same query...
    But the result is
    MAX(ID)
    9
    Please help me... What is the reason?
    I want the correct result...
    Thanks in advance....                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Kamran Agayev A. wrote:
    Yes you can use TO_NUMBER inside MAX function and it will not give any error in the futureHave you tested it?
    SQL> create table a (id,name,deleted)
      2  as
      3  select '2', 'XYZ', 'N' from dual union all
      4  select '3', 'ABD', 'N' from dual union all
      5  select '4', 'GJK', 'N' from dual union all
      6  select '5', 'GJK', 'N' from dual union all
      7  select '6', 'HGY', 'N' from dual union all
      8  select '7', 'YJG', 'N' from dual union all
      9  select '8', 'PIN', 'N' from dual union all
    10  select '9', 'BMF', 'N' from dual union all
    11  select '10', 'OLG', 'N' from dual
    12  /
    Tabel is aangemaakt.
    SQL> select max(id)
      2    from a
      3   where deleted = 'N'
      4  /
    MA
    9
    1 rij is geselecteerd.
    SQL> select max(to_number(id))
      2    from a
      3   where deleted = 'N'
      4  /
                        MAX(TO_NUMBER(ID))
                                        10
    1 rij is geselecteerd.
    SQL> insert into a values ('2A', 'ABC', 'N')
      2  /
    1 rij is aangemaakt.
    SQL> select max(to_number(id))
      2    from a
      3   where deleted = 'N'
      4  /
    select max(to_number(id))
    FOUT in regel 1:
    .ORA-01722: invalid numberRegards,
    Rob.

  • Use of MAX function

    Hi,
    I am using parent-child hierarchy and in my reports I want to show Max(hierarchy_level). When I use the function MAX directly in the report it works fine in every way. But I want to have this kind of column in the BI Server presentation catalog so the user does not need to add MAX in Analysis/Answers (this is 11g). Normally this would imply a Max(hierarchy_level) as a logical function, but in the BI Server it is not allowed with MAX function in the logical function so it does not work.
    The hierarchy level is just a column from a dimension table and creating it as a fact column is not a very good solution. I also tried to solve this in many different ways, but only the MAX funtion in Analysis/Answers allways give the correct result. Used in combination with other dimensions etc. I want the exact same behaviour as I get when using MAX in analysis.
    Any good ideas to solve this? Is there another function in the BI Server that works the same way as MAX ?

    Very often, about a primary key, see for example our italian accounting application (our VAT invoices:fatture IVA) ), where the holes might be a problem.
    Yes Rosario, of course I know that, and that's why I said "in this scenario" : if primary key is the only purpose, I don't think holes could be a problem.
    Buona giornata anche a te.

  • Use of MAX function in Query Designer

    Dear all,
    i want to create a report that gives ONE line per period that holds the MAX of several lines per period. So NO addition of the KF but just one line item.
    I tried to use the MAX function and/or MAX drop-down boxes via properties on KF,
    but they all provide the wrong result (mostly the MAX after summaction of the KF).
    Any ideas ??
    Greetz,
    Herman

    Hi Herman
        Please check the KF infoobject property which might have been set to Summation.  You need to change the property of the KF to MAX if you wish to have MAX value. 
        Hope this might be helpful to you
    Thanks
    Kishore Kusupati

  • How to use MAX function in SSAS MDX Query

    I want to run this Query with MAX Condition on LAST_DATA_UPDATE Column .

    Hi Ashishsingh,
    According to your description, you want to know how to use MAX function in SQL Server Analysis Services MDX Query, right? In this case, please refer to the link below which describe the syntax and sample of MDX function.
    http://technet.microsoft.com/en-us/library/ms145601.aspx
    http://www.mdxpert.com/Functions/MDXFunction.aspx?f=64
    Hope this helps.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Oracle:how to use max() function in case expression

    how to use max() function in case expression, Please explain with any example

    Hope this helps and should be self explanatory
    with t as
    (select 1 col,100 col2 from dual union
    select 2 ,100 from dual union
    select 2 ,200 from dual union
    select 3,100  from dual union
    select 3,200  from dual  )
    select col, case when max(col2)=100 then 'with 100 range'
    when  max(col2)=200 then 'with 200 range' end  from t group by col

  • How to use MAX() function with date field

    Hi Frzz,
    I have created a Graphical calculation view in which i have multiple records for each employee with different dates. But my requirement is to take the records which have maximum date.
    I have converted the date into Integer and applied the MAX() function. But still am getting multiple records.
    Is there is any other way we can achieve this requirement in Graphical Calculation view??  Your suggestion will really help me.
    Thank  you.
    Krishna.

    Hmm... what have you tried out so far?
    Look, I took the effort and created a little example, just for you
    Assume we have a table that contains the logon dates of users.
    Every line contains the logon date and some info on the user.
    Very much like a not-normalized log file could look like.
    Now, the output we want is: one line per user with the most current logon time.
    Not too difficult:
    1. Have a aggregation node that gives you the distinct user details - one line for every user:
    2. Have another aggregation node that gives you the last (MAX) logon date per user:
    Finally you do a 1:1 join on the USER_ID and map the result to the output.
    Easy as pie
    - Lars

Maybe you are looking for