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
Similar Messages
-
Advantages of using Bex WAD over Bex Query Designer?
Can anyone tell me the advantages of using Bex WAD over Bex Query Designer?
Hi Shiva,
WAD has many advantages when compared with Query Designer. few of those are
You can include Radio Buttons, Push Buttons, Check Boxs.....
You can include more than one report in one WAD Report
Completely u can make fancy as much as requried ....
Many graphs and chars are can be included .....
data from Views can be viewed
Many..many.... -
Can I use Count, Max function in PLSQL BLOCK.
Can U help me to use count, max function in PLSQL BLOCK.
Because it is giving me error "It is a SQL function"SELECT COUNT(*)
INTO l_variable
FROM dual;
Will work inside PL/SQL -
How to create user function in Data Functions in Query Designer?
Could someone tell me how to create user function in Data Functions in Query Designer?
I mean function like "NDIV0" in Data Functions.
SAP BW 3.x.
Query Designer (SAP BW 3.x)Hi check the following URL, it gives how to add in Formulas in formula Builder, not in DataFunctions.
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f095592f-42f7-2a10-6ab1-c836a559b48f
Thanks
Reddy -
I can't use the distribute function in livecycle design?
I can't use the distribute function in livecycle design?
I have spent many hours designing this and the feature is not able to work it is greyed out.
I am using adobe XI (not pro). What am I doing wrong?Hello,
Do you want to make the form editable?
If yes,
To make this you need to Reader Extend the form by following steps.
- Open the form in Acrobat Professional.
- Click on Advanced option and then on Enable usage rights…here you can select the various usage rights to be enabled.
- Save the file.
Now you can distribute this form and users can fill in save for their records, print.
-Vijay -
Add a mathematical function in Query Designer ?
Hi,
Do you know if it is possible to add a function in the Query Designer on formula screen ? If yes ... how ?
Thanks a lot,
CG.You can use the CEIL and FLOOR Functions for this
Suppose you have a Key Figure K.F . hide this key figure and create a new formula Key Figure and create a formula as shown below.
( FRAC ( 'K.F' ) >= 0.5 ) * CEIL ( 'K.F' ) + ( FRAC ( 'K.F' ) < 0.5 ) * FLOOR ('K.F' )
CEIL, FLOOR and FRAC will be available under Mathematical Functions -
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. -
How to use min-max functions for date in transformation in bpel?
Hi,
I have a requirement where i need to map earliest date of a Source field among all the dates to a target field in a transformation file in BPEL. There are functions called max-value-among-nodeset and min-value-among-nodeset in mathematical functions but they can be used only for numbers and strings.How to do these with dates?
Thanks,
PrasannaI exactly have the same requirement.Are you able to solve this?
Its very urgent.Please help me. -
Using the max function in a inner joined statement
I am trying to take from a database with two joined tables various datas from the record belonging to paul that has the highest entry number.
String query = "SELECT Table1.name, Table1.idNumber, Table2.Address Table2.entryNum FROM Table1 INNER JOIN Table2 ON Table1.idNumber = Table2.idNumber WHERE Table2.entryNum = max ( Table2.entryNum) AND Table1.name = 'Paul'";
The error message i get is.
Cannot have aggregate function in WHERE clause
Thanks for any helpI am trying to take from a database with two joined
tables various datas from the record belonging to paul
that has the highest entry number.SELECT
Table1.name,
Table1.idNumber,
Table2.Address
Table2.entryNum
FROM Table1 INNER JOIN Table2 ON Table1.idNumber = Table2.idNumber
WHERE Table2.entryNum =
( select max( Table2.entryNum) from table1, table2
where table1.idNumber=table2.idNumber
AND Table1.name = 'Paul'" ); -
Exclude a hierarchy node by using exit variable (not in query designer)
Hi gurus!!
I have a hierarchy for the infoObject 0COSTELMNT. Depending on the user who executes the report, the node '0599ADJUSTMENTS' must be displayed or not.
I am trying to solve it by using an exit variable:
Varible Type: Hierarchy Node
Processing : Exit
On the exit, I have entered the following code:
IF ( sy-subrc = 0 ).
l_s_range-sign = 'E' .
l_s_range-opt = 'EQ' .
l_s_range-low = 'AJUSTES'.
APPEND l_s_range TO e_t_range.
ENDIF.
But unfortunately does no work!!
Any ideas?
Thanks in advance
Regards.
Carmen RodríguezHi,
Check the below link gives good knowledge on variables:
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/579b3c494d8e15e10000000a114084/content.htm
Reg
Pra -
How to use select max and min query..
hi gurus,
we have got a custom report for develoment.
the report has to fetch the max and min salarys department wise....
how to pick up max & min sal ansal from table pa0008.Hi,
Try the following
select max(sal)
min(sal)
from <database table>
into <internal table>
group by department
where <where condition>.
Here we assume that sal is the field holding the salary and department is the name of the field in the database table. Where condition is optional.
Hope this helps.
Regards,
Sachin -
Using Calendar Year Month in query designer to populate a Month Structure
Hi
Is it possible to create a query that has a standard structure of Month Columns (Jan-Dec) with each month column populated by the correct 0CALMONTH (similar infoobject) value? I would also like to be able to filter this by the correct year selected since this will be a filter value.
Thanks for any help on this.Hi,
I would also like to be able to filter this by the correct year selected since this will be a filter value.
Yes. With the structure it is possible. But user input 0fiscalyear variable should be there to get the correct year data.
Hope it helps -
How to create/use SAP Exit variable of Query designer
Hello experts,
Can you please guide me on how to create/use SAP Exit variables ?
Is there any way we can transport customer exit include in which we write all codes related to customer exit variables?
Kindly provide your valuable inputs on this.
Thanks,
MiteshHello Gautam,
I think you should first implement the user-exit via the transaction SMOD/CMOD and the SAP-Enhancement RSR00001 User-Exit ( BW Reporting )
For the concrete implementation I would suggest to encapsulate the variables, as it is described here
Easy implementation of BEx-Userexit-Variables
and here: BEx-Userexits reloaded
Kind regards,
Hendrik -
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 -
Using Max Function in View Criteria
Hi
I am having a requirement where by i need to make use of max function in view criteria but not able to see any such option. Can someone please help me over it. Here is the requirement.
In table i will be having multiple rows for an employee and i need to pick latest row based on a column say request_id For e.g.
Emp RequestId
A 1
A 2
A 3
A 4
So if i pass the employee id i should get Row Number 4. In simple SQL language I want something like this
select * from emp where empid=A and requestid=( select max(requestid) from emp where empid=A)
Just wanted to know is there any approach that i can use to do all this as part of View Criteria or any other way.
Any help is appreciated!!!
Thanks
AJOne way is this -
1)https://blogs.oracle.com/adf/entry/using_groovy_aggregate_functions_in (You might need to create a self-referencing VL for this , try if it works using a ViewAccessor too)
OR
Order by RequestId descending in your SQL for the VO if thats ok , then have the ViewCriteria for the EmpId and programmatically pickup the first row...
Maybe you are looking for
-
Deleted from Library, not from media folder, How to delete from media fldr?
I attempted to delete a whole bunch of songs--iTunes asked: "Do you want to delete the selected song, or keep it in the itunes media folder?" I selected "keep file" by accident--so they are no longer in my library but still in my media folder. How do
-
Copy AP Configuration Templates-WCS 7.0.172.0
I am wondering if anyone has seen a way to copy an AP configuration template. We have several distribution centers and the templates are essentially identical other than the Template name and the AP Group VLAN (different for each DC). We set up a new
-
HI I am extracting the data from 0FI_GL_12. By default partner profit center is available in extractor. In BI datasource, partner profit center is selected and after executing the info package I am getting 200,000 records into PSA Then I removed tick
-
Posting IDocs, partner profile setting
Hello, I want to ask for advice. It happens IDoc hangs on R/3 side while requesting data to load them to BW. This IDoc has no error and after manual processing (BD87) data are transfered correctly and IDoc posted. It is message type : RSRQST and it h
-
Move or Copy pages between documents
In the Adobe Help Menu it says... If you copy a page from a document that has a different size than the document you are copying to, it will be resized to the dimensions of the destination. I can not get this to work. Can copy from doc to doc, but ad