How to pull a max value/first value for duplicates in a group in a query?

Hi everybody,
[Oracle 10g]
I'm working with two tables, tblPatient and tblProgressNotes. The fields I'm working with are:
<pre>
<li>tblPatient.PatientID</li>
<li>tblPatient.EpisodeNumber (this tracks the number of hospital visits)</li>
<li>tblPatient.DischargeDate</li>
<li>tblProgressNotes.Height</li>
<li>tblProgressNotes.Weight</li>
<li>tblProgressNotes.Girth</li>
<li>tblProgressNotes.EntryDate</li>
<li>tblProgressNotes.EntryTime</li>
</pre>
From the fields above, I need to pull the most recent episode for each patient and each unique entry date so I can collect the height, weight, girth, and chart the plots on a graph. The problem I'm running into, though, is that there may be multiple entries on a given day. I can get the most recent episode for each patient with a "WHERE tblPatient.DischargeDate Is Null," but I'm not sure how to pull just the unique dates for each patient.
For instance, if I have the following:
<pre>
     <u>PatientID EpisodeNumber EntryDate EntryTime Height Weight Girth</u>
1 1 01.01.13 1:03 PM 66 185 35.5
1 1 01.01.13 7:18 PM 66 184 36
1 1 01.07.13 8:57 AM 66 190 36
1 1 01.07.13 11:32 AM 66 189 35.5
</pre>
For the first two records, I only want to return one record on 01.01.13. What I would really like, if there is more than one entry on a single day, is to take the average of the height, weight, and girth entries for that day and return a single record (I don't need the time entries, but I included them initially for testing). So, this is what my desired output would look like:
<pre>
     <u>PatientID EpisodeNumber EntryDate Height Weight Girth</u>
1 1 01.01.13 66 184.5 35.75
1 1 01.07.13 66 189.5 35.75
</pre>
If it's not possible to write a query like the above, then I would like to take the first entry for each day where there are multiple entries on that day. So, this would be the desired output (I included the EntryTime again so you can compare to the original example):
<pre>
     <u>PatientID EpisodeNumber EntryDate EntryTime Height Weight Girth</u>
1 1 01.01.13 1:03 PM 66 185 35.5
1 1 01.07.13 8:57 AM 66 190 36
</pre>
Thanks for your help.

Hi,
987019 wrote:
Here's some sample data:
CREATE TABLE TBLPATIENT
PATID VARCHAR2 (20),
EPISODE_NUMBER DOUBLE,
DATE_OF_DISCHARGE DATE
CREATE TABLE TBLPROGRESSNOTES
PATID VARCHAR2 (20),
EPISODE_NUMBER DOUBLE,
DATA_ENTRY_DATE DATE,
GIRTH VARCHAR2 (5),
HEIGHT DOUBLE,
WEIGHT DOUBLE,
Thanks. I had to make some changes to get it to run:
CREATE TABLE TBLPATIENT
        PATID               VARCHAR2 (20),
        EPISODE_NUMBER           BINARY_DOUBLE,     -- There's no DOUBLE data type in SQL
        DATE_OF_DISCHARGE      DATE
DROP TABLE     tblprogressnotes;
CREATE TABLE TBLPROGRESSNOTES
        PATID          VARCHAR2 (20),
        EPISODE_NUMBER      NUMBER,          -- Most people use NUMBER for all numeric types
        ENTRY_DATE      DATE,          -- DATA_entry date is a good name, too, just be consistent
        GIRTH           NUMBER,          -- Can't average VARCHAR2s
        HEIGHT          NUMBER,
        WEIGHT           NUMBER          -- no comma here
INSERT INTO TBLPATIENT VALUES (1, 1);
INSERT INTO TBLPATIENT VALUES (2, 1);
// For the first 3 records, the height stays the same, but the girth and weight values are variable on the same day
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/01/2013 00:00:00', 'MM/DD/YYYY HH:MM:SS'), 36, 66, 184);
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/01/2013 00:00:00', 'MM/DD/YYYY HH:MM:SS'), 35.5, 66, 185);
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/01/2013 00:00:00', 'MM/DD/YYYY HH:MM:SS'), 35, 66, 184.5);
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/18/2013 00:00:00', 'MM/DD/YYYY HH:MM:SS'), 36, 66, 187);
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/31/2013 00:00:00', 'MM/DD/YYYY HH:MM:SS'), 36.5, 66, 190);
// For the last 3 records, the girth and height stay the same, but the weight is variable on the same day.
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/03/2013 00:00:00', 'MM/DD/YYYY HH:MM:SS'), 32, 66, 137.5);
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/08/2013 00:00:00', 'MM/DD/YYYY HH:MM:SS'), 32.5, 66, 138);
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/19/2013 00:00:00', 'MM/DD/YYYY HH:MM:SS'), 31, 66, 134);
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/19/2013 00:00:00', 'MM/DD/YYYY HH:MM:SS'), 31, 66, 133.5);
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/19/2013 00:00:00', 'MM/DD/YYYY HH:MM:SS'), 31, 66, 134.5);
INSERT INTO TBLPATIENT VALUES (1, 1, NULL);
-- If the table has 3 columns,     ^^^^^^  INSERT 3 values (or say which columns you're INSERTing)
INSERT INTO TBLPATIENT VALUES (2, 1, NULL);
// For the first 3 records, the height stays the same, but the girth and weight values are variable on the same day
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/01/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 36, 66, 184);
--                                                             MM = month  ^^            ^^ MI = minutes
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/01/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 35.5, 66, 185);
--                                                         Hour 00  ^^  not valid for HH   ^^^^  use HH24 instead
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/01/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 35, 66, 184.5);
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/18/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 36, 66, 187);
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/31/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 36.5, 66, 190);
// For the last 3 records, the girth and height stay the same, but the weight is variable on the same day.
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/03/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 32, 66, 137.5);
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/08/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 32.5, 66, 138);
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/19/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 31, 66, 134);
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/19/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 31, 66, 133.5);
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/19/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 31, 66, 134.5);This seems to be different from the sample data you posted earlier. You didn't say what results you want from this data, so I don't know if this gets them or not:
SELECT
        P.PATID,
        P.EPISODE_NUMBER,
        P.DATE_OF_DISCHARGE,
        M.ENTRY_DATE,
--      M.ENTRY_TIME,          -- Not needed (not present in simplified sample data, anyway)
        AVG (M.GIRTH)     AS avg_girth,             -- AVG added
        AVG (M.HEIGHT)     AS avg_height,
        AVG (M.WEIGHT)     AS avg_weight
FROM
        TBLPATIENT P LEFT OUTER JOIN
        TBLPROGRESSNOTES M ON
                (P.PATID = M.PATID) AND
                (P.EPISODE_NUMBER = M.EPISODE_NUMBER)
WHERE
        P.DATE_OF_DISCHARGE IS NULL AND
        M.ENTRY_DATE BETWEEN (SYSDATE - 60) AND SYSDATE AND
        M.HEIGHT  != 0 AND        -- This site won't display the other inequlaity operator
        M.WEIGHT  != 0
GROUP BY               -- GROUP BY clause added
        P.PATID,          -- Includes all columns from the SELECT clause that
        P.EPISODE_NUMBER,     --      are not aggregated
        P.DATE_OF_DISCHARGE,
        M.ENTRY_DATE
ORDER BY
        P.PATID,          -- No column called patIENTid
        M.ENTRY_DATE
-- ,    M.ENTRY_TIME
;As you can see, it's very close to what you posted, and to what I suggested earlier: use AVG on the columns that you want to average, and GROUP BY the other columns. I marked all the places I changed with in-line comments.
Since the hours, mintues and seconds of entry_date are always 00:00:00, then there's no need to use TRUNC (entry_date). Using it unnecessaily won't change the results, it will only waste a little time.
By the way, if you omit the hours, minutes and seconds in TO_DATE, they default to 00:00:00, so you could make the insert statements a little simpler like this:
INSERT INTO TBLPROGRESSNOTES VALUES (1, 1, TO_DATE('01/01/2013', 'MM/DD/YYYY'), 36, 66, 184);Output fro the query above:
`     EPISODE
PATID _NUMBER DATE_OF_DI ENTRY_DATE  AVG_GIRTH AVG_HEIGHT AVG_WEIGHT
1           1            01/01/2013       35.5         66      184.5
1           1            01/03/2013         32         66      137.5
1           1            01/08/2013       32.5         66        138
1           1            01/18/2013         36         66        187
1           1            01/19/2013         31         66        134
1           1            01/31/2013       36.5         66        190

Similar Messages

  • Input Value long enough for date format ,Error in executing parallel query

    Hi,
    My Table: ANML( ID, STATUS,B_DATE,B_MONTH,B_YEAR, DEATH_DATE)
    status 1 for alive and 2 for dead.
    i wrote a view to get age.
    as
    create or relace view view1 as
    select top."ID",top."STATUS",top."DOB",top."DEATH_DATE",top."ANML_AGE",top."DAYSDIFF",
    CASE
    WHEN anml_age < 1
    THEN 'D'
    ELSE 'M'
    END age_unit,
    CASE
    WHEN anml_age < 1
    THEN TO_CHAR (daysdiff || ' Day(s)')
    WHEN anml_age < 12
    THEN TO_CHAR (anml_age || ' Month(s)')
    WHEN MOD (anml_age, 12) = 0
    THEN TO_CHAR (ROUND (anml_age / 12, 0) || ' Year(s) '
    ELSE TO_CHAR ( ROUND (anml_age / 12, 0)
    || ' Year(s) '
    || MOD (anml_age, 12)
    || ' Month(s)'
    END age_string
    from
    (SELECT a.*,
    CASE WHEN status IN ( 1)
    THEN FLOOR(MONTHS_BETWEEN(TRUNC(SYSDATE),dob))
    WHEN death_date IS NOT NULL AND status IN (2)
    THEN FLOOR(MONTHS_BETWEEN(death_date,dob))
    END anml_age,
    CASE WHEN status IN (1)
    THEN FLOOR(TRUNC(SYSDATE)-TRUNC(dob))
    WHEN death_date IS NOT NULL AND status IN (2)
    THEN FLOOR(TRUNC(death_date) - TRUNC(dob))
    END daysdiff
    from (
    SELECTanml.id, status,
    TO_DATE ( DECODE (b_date,
    NULL, 1,
    b_date
    || '-'
    || DECODE (b_month,
    NULL, 1,
    b_month
    || '-'
    || b_year,
    'dd-mm-yyyy'
    ) DOB,
    death_date
    FROM anml
    WHERE b_year IS NOT NULL
    ) a) top
    when i tried to fetch all values from view its working fine.
    But when i tried to fetch values based on condition like as follows,
    select * from view1 where anml_age > 20 and anml_age<30
    I am getting error like:
    Input Value long enough for date format and Error in executing parallel query
    Please tell me wht is wrong.

    Here is your formatted code
    create or relace view view1 as
    select top."ID",top."STATUS",top."DOB",top."DEATH_DATE",top."ANML_AGE",top."DAYSDIFF",
    CASE
    WHEN anml_age < 1
    THEN 'D'
    ELSE 'M'
    END age_unit,
    CASE
    WHEN anml_age < 1
    THEN TO_CHAR (daysdiff || ' Day(s)')
    WHEN anml_age < 12
    THEN TO_CHAR (anml_age || ' Month(s)')
    WHEN MOD (anml_age, 12) = 0
    THEN TO_CHAR (ROUND (anml_age / 12, 0) || ' Year(s) '
    ELSE TO_CHAR ( ROUND (anml_age / 12, 0)
    || ' Year(s) '
    || MOD (anml_age, 12)
    || ' Month(s)'
    END age_string
    from
    (SELECT a.*,
    CASE WHEN status IN ( 1)
    THEN FLOOR(MONTHS_BETWEEN(TRUNC(SYSDATE),dob))
    WHEN death_date IS NOT NULL AND status IN (2)
    THEN FLOOR(MONTHS_BETWEEN(death_date,dob))
    END anml_age,
    CASE WHEN status IN (1)
    THEN FLOOR(TRUNC(SYSDATE)-TRUNC(dob))
    WHEN death_date IS NOT NULL AND status IN (2)
    THEN FLOOR(TRUNC(death_date) - TRUNC(dob))
    END daysdiff
    from (
    SELECTanml.id, status,
    TO_DATE ( DECODE (b_date,
    NULL, 1,
    b_date
    || '-'
    || DECODE (b_month,
    NULL, 1,
    b_month
    || '-'
    || b_year,
    'dd-mm-yyyy'
    ) DOB,
    death_date
    FROM anml
    WHERE b_year IS NOT NULL
    ) a) top

  • How do i check ensure that SAP checks for duplicate vendor invoice numbers?

    Hi Experts -
    How do I verify that SAP checks for duplicate vendor invoice numbers and blocks duplicate invoices from being paid?
    Thanks!

    Hi
    Pls chek the settigs by following the path
    IMG>Materials Management>Logistics Invoice Verification>Incoming Invoice>Set Check for Duplicate Invoice.
    Here you make the settings for creating a duplicate invoice check.
    Moreever, in the vendor master, you need to tick the check box for duplicate invoice check.
    I suggest you search the Forums before posting a query. There are lots of postings on this issue.
    Thanks & regards
    Sanil K Bhandari

  • How to add -Select- as the first value in dropdownbox?

    Hi All,
    I am having a dropdownbox with the set of values. I need to add -SELECT- as the first and default value. Please do advise how to achieve this.
    Code and screenshot below.
    var oModel = new sap.ui.model.odata.ODataModel("../../services/admin/typesTable.xsodata/", false);
    var oSort = new sap.ui.model.Sorter("ID", false);
    var lblType = new sap.ui.commons.Label();
    lblType.setText("Type");
    var ddbType = new sap.ui.commons.DropdownBox();
    ddbType.setRequired(true);
    var oItemTemplate = new sap.ui.core.ListItem();
    oItemTemplate.bindProperty("text", "NAME");
    oItemTemplate.bindProperty("key", "ID");
    ddbType.setModel(oModel);
    ddbType.bindItems("/TYPES", oItemTemplate, oSort);
    lblType.setLabelFor(ddbType);
    oChildLayout.createRow(lblType, ddbType);
    Thanks in advance
    Aravindh

    Hi,
    Refer this discussion on exact requirement empty/"all" entry in DropdownBox with OData model - cleanest solution
    Regards,
    Chandra

  • How to pull out a storage usage report for exadata platform

    Hi anyone knows how to get a report of storage usage in an exadata using ZFS?... without the use of OEM

    Hi
    ZFS has it own OEM console to monitor the ZFS storage.
    Where as exadata machine is monitored from OEM Cloud control 12C .
    You can see Exadata storage report from OEM Cloud control 12c. .
    -Thanks
    -Arjun B

  • Get only the first row for duplicate data

    Hello,
    I have the following situation...
    I have a table called employees with column (re, name, function) where "re" is the primary key.
    I have to import data inside this table using an xml file, the problem is that some employees can be repeated inside this xml, that means, I'll have repeated "re"'s, and this columns is primary key of my table.
    To workaround, I've created a table called employees_tmp that has the same structed as employees, but without the constraint of primary key, on this way I can import the xml data inside the table employees_tmp.
    What I need now is copy the data from employees_tmp to employess, but for the cases where "re" is repeated, I just want to copy the first row found.
    Just an example:
    EMPLOYEES_TMP
    RE NAME FUNCTION
    0987 GABRIEL ANALYST
    0987 GABRIEL MANAGER
    0978 RANIERI ANALYST
    0875 RICHARD VICE-PRESIDENT
    I want to copy the data to make employees looks like
    EMPLOYEES
    RE NAME FUNCTION
    0987 GABRIEL ANALYST
    0978 RANIERI ANALYST
    0875 RICHARD VICE-PRESIDENT
    How could I do this?
    I really appreciate any help.
    Thanks

    Try,
    SELECT re, NAME, FUNCTION
      FROM (SELECT re,
                   NAME,
                   FUNCTION,
                   ROW_NUMBER () OVER (PARTITION BY re ORDER BY NAME) rn
              FROM employees_tmp)
    WHERE rn = 1G.

  • How to increase ulimit max open files, permanently?

    I have a shell script that needs to be able to receive hundreds of incoming socket connections. The default max of open files is 256. Strangely, if I run:
    sudo ulimit -n 800
    ...ulimit -a still shows just 256 max open files. If I become root (sudo su), then I can increase the max files to 800, but that setting only remains while I'm root user.
    Anyone know how to increase the max open files setting for my regular user name, as I run scripts from the Terminal bash shell?
    ...Rene

    Wow, within 2 minutes, I realized what I had to do, so in case anyone else wonders the same, here's the solutions:
    Just edit the .bash_profile file in your home directory (create it if it's not already there), and add the line:
    ulimit -n 1024
    Now, whenever you start terminal, that process will be able to open up to 1024 files or socket connections.
    ...Rene

  • How to retrieve 3 max values

    Hi ,
    can anyone let me know how to retrive the max 3 values from a table...
    I want to get the top 3 values of salary from emp table
    Thanks,
    Praveen

    Praveen,
    Consider the following example:
    SQL> set pagesize 9999
    SQL> select empno, ename, sal
      2  from scott.emp;
         EMPNO ENAME             SAL
          7369 SMITH             800
          7499 ALLEN            1600
          7521 WARD             1250
          7566 JONES            2975
          7654 MARTIN           1250
          7698 BLAKE            2850
          7782 CLARK            2450
          7788 SCOTT            3000
          7839 KING             5000
          7844 TURNER           1500
          7876 ADAMS            1100
          7900 JAMES             950
          7902 FORD             3000
          7934 MILLER           1300If you want to get the top three salaries, you can use this query
    SQL> select sal
      2  from
      3     (select distinct sal
      4       from scott.emp
      5     order by sal desc)
      6  where  rownum<=3;
           SAL
          5000
          3000
          2975If you want to see all the employees having any of top-3 salaries you can use the following one:
    SQL> select empno, ename, sal
      2  from
      3     (select empno, ename, sal, dense_rank() over (order by sal desc) dr
      4      from scott.emp
      5     )
      6  where dr<=3;
         EMPNO ENAME             SAL
          7839 KING             5000
          7788 SCOTT            3000
          7902 FORD             3000
          7566 JONES            2975If you want to get the first 3 employees with the highest salaries. You can use the following one.
    But, be aware, there might be more employees having $3000,00 salary.
    SQL>  select empno, ename, sal
      2  from
      3     (select empno, ename, sal
      4      from scott.emp
      5     order by sal desc)
      6* where rownum<=3
    SQL> /
         EMPNO ENAME             SAL
          7839 KING             5000
          7788 SCOTT            3000
          7902 FORD             3000
    SQL>

  • How to get fourthly row (row4) first column value (col1) in matrix

    Hi to all,
    In FMS, how to get fourthly row (row4) first column value (col1) in matrix in document.
    select $[$38.1.4]
    But it display the first row
    Please give me hint.
    Thank you

    Hi Eric,
    FMS may only apply to current row.  There is no way to get any other fixed row.
    Thanks,
    Gordon

  • How to get the max value in the query??

    Plant  calday(mm.dd.yyyy)       Soldout.Qty
    0001   01.01.2005               10
    0001   01.02.2005               20
    0001   01.03.2005               05
    0001   01.04.2005               16
    0001   01.05.2005               10
    0001   01.06.2005               14
        From the above values , how can i findout Max(Soldout.Qty)(i.e 20) for the above week...Suppose present aggregation = summation...How can i findout the value in the Query??don't want to do changes to design...

    Hi Bhanu,
      I tried the calculation results as...Maximum,..
      But that will pick the maximum value among the avialable values..like
    plant1 max 10
    plant2 max 20
    plant3 max 30
    then it will show as..
    plant1 max 30
    plant2 max 30
    ...like this...but my case is
    plant1 calday1 10
    plant1 calday2 05
    plan1  calday7 08
    plant2 calday1 10
    plant2 calday2 05
    plan2  calday7 20
    so for each set it need to bring the maximum value...

  • How can I pull the BUKRS (company code) value, for a X_USER (sy-uname) inpu

    HI Experts,
    Pls. clarify that, How can I pull the BUKRS (company code) value, for a X_USER (sy-uname) as input?
    ThanQ.

    Check with USRM1 Table
    give user name (Uname ) and you get company code (BUKRS)
    also check with other tables : USRM* in SE11
    Thanks
    Seshu

  • Crystal Reports XI - How to pull same column value with different select...

    I have a report with many (around 30) sub reports and it is giving serious performance issue. I am currently finding out a strategy to improve the performance. I see that most of the sub reports are taking same parameters from main report except for one parameter which is different for each sub report and hard coded in them and pulling up the same column value from a oracle database with a different select criterion. I am trying to find out a way using either of command/crystal formula/SQL expression which can do the same job for me and give me performance improvement. I tried to take the parameters from the main report in one sub report and mapped them to parameters being transferred to the command and then drag and drop the field for which I need to display the value but due to some reason it is not returning values when I am trying multiple commands...I need some help in selecting a strategy for this issue resolution and some guidance....Any help would be highly appreciated....

    My version is 11.5.8.826. First of all I need to make it clear that I have 6 set of sub reports and each set has 5 sub reports. So if I can resolve the issue for one set, I resolve it for all. The sub reports are doing nothing but fetching a column value using a simple SQL SELECT query and appending to the right of a box in main report. The issue is that all these queries embedded into the sub reports are using same SQL except for one parameter in the "where" clause and they are fetching same column value from the database and fortunately all of them are returning same number of results. So at the end these results create a table when run. The only way I can stop using sub reports is by creating a table in the main report and use some object(formula/command/SQL expression or whatever) to fetch that column value using the same filter conditions. But please take a note that I need to use and append the same column value from a database table and use different filter conditions and append them to the right so that at the end they create a table...as long as I get the table in the output with a decent performance , anyone will be least bothered about what I used inside the report.....please ask me as many questions to get more lights on the issue....

  • How can I make the Dependant Dashboard Prompt to auto select first value

    Hi all,
    I have an City prompt and creating a presentation variable with another prompt which is limited with the City prompt. But I want the second prompt to select the very first value whenever the city prompt changes.
    How can I achive this to make a prompt to auto select the first value?
    OR, is there a way to create a presentation variable as a result of an SQL using the value of the prompt?
    Thank you so much.
    Ganim

    You can definitely have a prompt with SQL referring to the presentation variable as @{pv} where pv is the Presentation Variable. Also, you could assign a default value to the prompt in question.
    Please assign points if helpful/correct.

  • How to get the max value of a set of percentage values?

    Hi,
    I've tried to get the max and min value of a set of calculated percentage values. Such as
    Jan Feb March Apr May Jun    Min  Average   Max
    0,5 0,8  1,1      0,4 1      0,6     0,4   0,7         1,1
    The average value works fine. But with "min" and "max" I have a problem.
    I've tried to get the value with the following ways:
    - Create a new calc. keyfigure and make a sum of all values: (Jan + Feb + ...) and set the calculation in key figure properties to Min/Max.
    - Create a new calc. keyfigure and make a sum of all values and set the aggregation to Min/Max
    - Create a selected keyfigure with a filter to the necessary periods and set a calculation to Min (Aggregation is not possible here)
    - Create a new cal. keyfigure with all periods and the function Min. e.g. min(Jan, (min Feb, (min (....)
    None of this solutions provides the right min and max value. When I use an amount value (e.g. Euro) instead of these percentage values the keyfigure with the min and max function works. The others all provide wrong values.
    Is there a solution to get the right min and max value???
    It would be a great help when you have any hints.
    Thanks
    Claudia

    Hi Aduri,
    thanks for your answer but your solution doesn't work.
    The problem is that the periods are defined in a structure with offsets such as
    - period-11
    - period-10
    - period
    in this structure elements there is also the keyfigure "netvalue" defined.
    In the rows of the report there is another characteristic such as company code.
    Is there a solution to find the max and min values of the period values for each company code? Or must I change the data model e.g. copy the keyfigure and make a new keyfigure with another aggregation level?
    Thanks for any hints!
    Claudia

  • How to get Long Max Value

    Hi All,
    Hope someone can give a shot with this prob of mine..
    I am trying to get the maximum value of long for the yielded millisecond(type long) using this statements..
    Long ldg = new Long (trialTime.getTime());
    long date = ldg.MAX_VALUE;
    but i keep on getting the same output which is 9223372036854775807
    am i doing it right? or is there a poitnm im missing at...
    thanks in advance

    It was kind of difficult to understand the question here. Long.MAX_VALUE always returns the maximum long value possible. If you wanted to get the maximum value returned by several calls to trialTime.getTime(), you could use Math.max(long, long)
    something like
    long max = Long.MIN_VALUE;
    and everytime you call trialTime.getTime(), do this
    max = Math.max(max, trialTime.getTime());
    this way max will always contain the maximum value returned by trialTime.getTime()
    dunno if this answered your question at all.

Maybe you are looking for