MDX Query for Average customer first sale amount for each year
Hello,
I new to MDX, and I am looking to build a query that would get all the first sale amount for the customes and average that. The intent is to use find an average each year. I am looking to use this against the adventure works database.
I am not sure exatcly how to start this . Any help is much appreciated.
J
Hi,
I'll do it in several stages.
let's first define an ordered set of date/sale to one customer over all periods:
SELECT
{[Measures].[Internet Sales Amount]} ON 0
NonEmpty
[Date].[Calendar].[Date]
[Customer].[Customer].&[15561]
,[Measures].[Internet Sales Amount]
,[Customer].[Customter].&[15561]
) ON 1
FROM [Adventure Works];
we retain the first line of the result set with item(0):
SELECT
{[Measures].[Internet Sales Amount]} ON 0
NonEmpty
[Date].[Calendar].[Date]
[Customer].[Customer].&[15561]
,[Measures].[Internet Sales Amount]
,[Customer].[Customer].&[15561]
).Item(0) ON 1
FROM [Adventure Works];
next, for each year we define a measure that will retain the first sale for each customer
(I limit the customer set to the first 2000)
WITH
MEMBER [Measures].[Mymeasure 2006] AS
NonEmpty
Exists
[Date].[Calendar].[Date].MEMBERS
,[Date].[Calendar].[Calendar Year].&[2006]
[Customer].[Customer].CurrentMember
,[Measures].[Internet Sales Amount]
,[Customer].[Customer].CurrentMember
).Item(0)
,[Measures].[Internet Sales Amount]
MEMBER [Measures].[Mymeasure 2007] AS
NonEmpty
Exists
[Date].[Calendar].[Date].MEMBERS
,[Date].[Calendar].[Calendar Year].&[2007]
[Customer].[Customer].CurrentMember
,[Measures].[Internet Sales Amount]
,[Customer].[Customer].CurrentMember
).Item(0)
,[Measures].[Internet Sales Amount]
SELECT
[Measures].[Mymeasure 2006]
,[Measures].[Mymeasure 2007]
} ON 0
,NON EMPTY
Head
[Customer].[Customer].[Customer]
,2000
) ON 1
FROM [Adventure Works];
We then take the average for each year:
WITH
MEMBER [Measures].[AVG cust first sale 2006] AS
Avg
Head
[Customer].[Customer].[Customer]
,2000
NonEmpty
Exists
[Date].[Calendar].[Date].MEMBERS
,[Date].[Calendar].[Calendar Year].&[2006]
[Customer].[Customer].CurrentMember
,[Measures].[Internet Sales Amount]
,[Customer].[Customer].CurrentMember
).Item(0)
,[Measures].[Internet Sales Amount]
MEMBER [Measures].[AVG cust first sale 2007] AS
Avg
Head
[Customer].[Customer].[Customer]
,2000
NonEmpty
Exists
[Date].[Calendar].[Date].MEMBERS
,[Date].[Calendar].[Calendar Year].&[2007]
[Customer].[Customer].CurrentMember
,[Measures].[Internet Sales Amount]
,[Customer].[Customer].CurrentMember
).Item(0)
,[Measures].[Internet Sales Amount]
SELECT
[Measures].[AVG cust first sale 2006]
,[Measures].[AVG cust first sale 2007]
} ON 0
FROM [Adventure Works];
Philip,
Similar Messages
-
Wht r the standard tables for vendor customer and sales order report/
Hi wht r the standard tables for vendor and customer reports and is how in normal we cannot use them for vendor reporting and etc ?
Hi
Customer is related to Sales Module
So for a customer we fetch the reports of Sales orders , Deliveries and Billing doc's
CUstomer and Vendor related tables with important fields:
KNA1: Customer Master-General(KUNNR,NAME1,LAND1)
KNB1: Customer Master(Company Code)(KUNNR,BUKRS,PERNR)
KNC1: Customer Master Data (Transaction Figures)(KUNNR,BUKRS,GJAHR)
KNVK: Customer Master Contact Partner(PARNR,KUNNR,NAME1)
KNVV: Customer Master sales data(KUNNR,VKORG,VTWEG,KDGRP)
KNBK: Customer Bank Details(KUNNR,BANKS,BANKL,BANKN)
KNVH: Customer Hierarchy (HITYP,KUNNR,VKORG,VTWEG,SPART)
KNVP: Customer Master Partner Functions(KUNNR,PARVW,KUNN2)
KNVS: Customer Shipment data(KUNNR,VSTEL,TRANS)
KNVI: Customer Tax data(KUNNR,ALAND,TATYP)
LFA1: Vendor Master-General (LIFNR,NAME1,ORT01)
LFB1: Vendor Master(Company Code)(LIFNR,BUKRS,PERNR)
LFC1: Vendor Master (Transaction Figures)(LIFNR,BUKRS,GJAHR)
Sales related Tables for a customer
VBAK: Sales Document(Header Data) (VBELN, KUNNR)
VBAP: Sales Document(Item Data) (VBELN,POSNR,MATNR,ARKTX,CHARG)
Enquiry, Quotation, Sales Order are differentiated based on Doc.
Type(VBTYP field) in VBAK,VBAP Tables( for Enquiry VBTYP = A,
for Quotation 'B' & for Order it is 'C'.)
LIKP: Delivery Table (Header Data)(VBELN,LFART,KUNNR,WADAT,INCO1)
LIPS: Delivery Table (Item Data)(VBELN,POSNR,WERKS,LGORT,MATNR,VGBEL)
(LIPS-VGBEL = VBAK-VBELN, LIPS-VGPOS = VBAP-POSNR)
VTTK: Shipment Table (Header Data)(TKNUM)
VTTP: Shipment Table (Item Data)( TKNUM,TPNUM,VBELN)
(VTTP-VBELN = LIKP-VBELN)
VTFA: Shipping Document Flow(TKNUM,VBELV,VBELN)
VTPA: Shipping Partners data(VBELN,PARVW,KUNNR,PERNR)
VTTS: Stages in Shipment(TKNUM,TSNUM,TSTYP)
VTSP: Transport Stage/Shipment Item Allocation(TKNUM,TSNUM,TPNUM)
VEKP: Handling Unit: Header(Packing)(VENUM,VSTEL)
VEPO: Handling Unit: Item (Packing)(VENUM,VEPOS,VBELN)
VBRK: Billing Table(Header Data)(VBELN,FKART,BELNR)
VBRP: Billing Table(Item Data)(VBELN,POSNR,FKIMG,NETWR,VGBEL,VGPOS)
(VBRP-AUBEL = VBAK-VBELN, VBRP-VGBEL = LIKP-VBELN)
Apart from these tables there are lot of other tables which starts with
V, but we use the following tables frequently.
VBUK: All Sales Documents status & Admn. Data(Header)(VBELN,VBTYP)
VBTYP= C(Sales Order) VBTYP=J(Delivery) VBTYP=M(Invoice)
VBUP: Sales Documents status & Admn. Data(Item)(VBELN,POSNR)
VBEP: Sales Doc. Schedule Lines Data(VBELN,POSNR,EDATU,WMENG)
VBKD: To get sales related Business data like Payment terms etc.(VBELN,ZTERM)
VBFA: sales document flow data(VBELV,VBELN,POSNV,VBTYP)
VBPA: Partner functions Data(VBELN,PARVW,KUNNR,LIFNR)
VEDA: Contract Data(VBELN,VPOSN)
VEDAPO: Contract Data(VBELN,VPOSN)
Vendor related MM tables
EBAN-- Pur.Reqn. Data (BANFN,BNFPO,BADAT,MATNR)
EBKN-- Purchase Requisition Account Assignment(BANFN,BNFPO,VBELN)
EINA- Purchase Info.Record (General Data)(INFNR,MATNR,LIFNR)
EINE-- Purchase Info.Record (Pur.Orgn Data )(INFNR,EKORG)
ELBK-- Vendor Evaluation Header Data(LIFNR,EKORG,KLASS)
EKKO-- Purchase Order Data (Header)(EBELN,BSTYP,BSART)
EKPO-- Purchase Order Data (Item)(EBELN,EBELP,MATNR)
RFQ and PO are differentiated by Doc Type(BSTYP)in EKKO table.
For RFQ it is A and for PO it is F.
MKPF-- GRN Data (Header) (EBELN,BLDAT,BUDAT,XBLNR,BKTXT)
MSEG-- GRN Data (Item)(MBLNR,BWART,LIFNR,MATNR,EBELN)
Apart from this there are lot of tables which begin with 'M'& 'E', but we
use the following very often.
EKBE--PO History Data (EBELN,EBELP,BELNR,BLDAT,MATNR,VGABE)
EKBZ--PO History with delivery Costs(EBELN,BELNR,LIFNR,XBLNR)
EKET--Schedule lines data of a PO (EBELN,EINDT,SLFDT)
EKES--Vendor Confirmations Data(EBELN,EBTYP,EINDT,XBLNR)
Reward points if useful
Regards
Anji -
Query To Return Sale Amount For Specified Employee
Below is my DDL - How can (in one query) I input an employee name and from the given employee name display all stores that were worked at and Total sale amounts per store for the specified employee? Sample output would be
Store Name Employee Name Sale Amt
Two afaslkfasd
100
Five aslkjfla 300
Create Table StoreInfo
storeid int IDENTITY(1,1) PRIMARY KEY,
storename varchar(100),
employeeid int,
employee varchar(100)
Create Table SaleInfo
saleid int IDENTITY(1,1) PRIMARY KEY,
storeid int,
employeeid int not null,
saleamount int,
dateofsale SMALLDATETIME null
INSERT INTO StoreInfo VALUES
('One', 1, 'Mike Jones'),
('Two', 2, 'Lee Jones'),
('Three', 3, 'Fred Marx'),
('Four', 4, 'Lillard Halfling'),
('Five', 5, 'Joey Fratada'),
('Six', 6, 'Lethan James'),
('Seven', 7, 'Four-Finger Charlie'),
('Eight', 8, 'Twice Sold'),
('Nine', 9, 'Richard Jackson'),
('Ten', 10, 'Fred Mitch')
INSERT INTO SaleInfo VALUES
(1,1,452, '12-21-14'),
(1,1,452, '9-7-14' ),
(1,2,500, '12-7-14' ),
(1,3,100, '3-12-14' ),
(1,6,275, '12-2-14' ),
(1,7,800, '1-12-14' ),
(2,4,200, '2-16-14' ),
(2,5,110, '12-7-14' ),
(2,1,120, '8-12-14' ),
(2,3,320, '2-22-14' ),
(3,3,50, '3-12-14' ),
(3,1,75, '8-2-14' ),
(3,8,20, '7-12-14' ),
(3,9,42, '12-8-14' ),
(4,10,52, '12-16-14' ),
(4,1,152, '12-4-14'),
(4,8,452, '5-1-14'),
(4,7,752, '2-28-13' ),
(4,6,52, '1-22-14' ),
(4,2,42, '12-28-13' )Thank you for trying to post the DDL we need to answer this. But you do not know RDBMS, or industry and ANSI/ISO standards in your data. You should learn ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal
data. Your choice of proprietary date format is literally the worst way to do it! Why do you think that IDENTITY has any place in RDBMS? Where were you when they discussed keys? You also have no idea what a normalized table is. An employee has a relationship
with a store; he is not an attribute of one! When you fire an employee, you destroy a store in your schema.
Do people in your world have hundred letter names? The Post office uses 35 for an address line. If you invite garbage data, it will come.
Why do you think that “_info” is a valid table name? Why are prices expressed in integers and not decimals? What currency on Earth is not decimal?
You need to read and download the PDF for:
https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
Below is my DDL - How can (in one query) I input an employee name and from the given employee name display all stores that were worked at and Total sale amounts per store for the specified employee?
Why don't you use DRI? That is what RDBMS is all about.
CREATE TABLE Stores
(store_nbr CHAR(3) NOT NULL PRIMARY KEY
CHECK (store_nbr LIKE '[0-9][0-9][0-9]'),
store_name VARCHAR(35) NOT NULL);
CREATE TABLE Personnel
(employee_id CHAR(10) NOT NULL PRIMARY KEY,
employee_name VARCHAR(35)NOT NULL);
Since we have no business rules, I will assume each employee is at one and one store, but a store can have many employees.
CREATE TABLE Job_Assignments
(store_nbr CHAR(3) NOT NULL
REFERENCES Stores(store_nbr)
employee_id CHAR(10) NOT NULL PRIMARY KEY
REFERENCES Personnel (employee_id));
The sales tickets can be a CREATE SEQUENCE but let's skip that for now. I swill not re-copy your data into this valid schema, but you might want to do it to learn how.
CREATE TABLE Sales
(sale_ticket INTEGER NOT NULL PRIMARY KEY,
store_nbr CHAR(3) NOT NULL
REFERENCES Stores(store_nbr)
employee_id CHAR(10) NOT NULL
REFERENCES Personnel (employee_id),
sale_amount DECIMAL(12,2) NOT NULL,
sale_date DATE DEFAULT CURRENT_TIMESTAMP NOT NULL);
>> How can (in one query) I input an employee name and from the given employee name display all stores that were worked at and Total sale amounts per store for the specified employee? <<
SELECT employee_name, store_name,
SUM(T.sale_amount) AS sales_amt_tot
FROM Sales AS T, Personnel AS P, Stores AS S
WHERE P.employee_name = @in_employee_name
AND T.employee_id = S.Employee_id
AND T.store_id = S.store_id
GROUP BY employee_name, store_name;
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
How to maintain Authorized buyer for a customer in Sales Order.
Dear all,
We have a corporate customer, which has 10 authorized buyers. We have created a Customer number for this company.
But at time of sales order creation, we need enter the authorized buyer name in sales order for the record purpose.
we are not creating any authorized persons in the system.
but our management want to see the person name who is buying behalf of the corporate customer.
for that we need to prepare a report.
I think SAP must be having a standard solution to address this requirement.
I request you to help me to resolve this issue. Your suggestions will be highly appreciated.
thank you
Raghu Ram
Edited by: Raghu Ram on Apr 21, 2008 8:24 AMHI,
I think u want to create agent who is buying material on behalf of customer. For report purpose u can create commision agent in Partner det . procedure for this purpose.
Thanks,
Pramod -
Purchase Order missing for some of the Sales Order for few customers
Hi All,
There are few sales orders for which corresponding PO is missing.
But most of other Sales orders for the same set of customers, PO is coming.
Could you please enlighten me how this PO is assigned to the Sales order or it is updated with the Inbound Idoc ..
In any case what may be the reason for PO missing for these sales order...How I can explore this...?
Thanks,
SanjeetHi sanjeet,
If your IDOC is ORDERS05, Check if you are getting the PO Number in : E1EDK01-BELNR
Regards,
Ravi -
FM for giving the total bill amount for a specific billing month in IS-U
Can anybody help me with a function module which will give sum for all the bill amounts shown in transaction code EA22 in IS-U.
I just want to know the total bill amount for given billing period but through a FM.
Thanx in advance.Hi Vinay, check out this as it may be of some help 4 u.
In the fM "BAPI_BILLINGDOC_CREATEMULTIPLE",
In the tables Parametr , u need to pass BILLINGDATAIN which contains the SD docu No (REF_DOC).
The following are the Required entries :
BILLING_DATA_IN-SALESORG
BILLING_DATA_IN-DISTR_CHAN
BILLING_DATA_IN-DIVISION
BILLING_DATA_IN-DOC_TYPE
BILLING_DATA_IN-ORDBILLTYP
BILLING_DATA_IN-SOLD_TO
BILLING_DATA_IN-ITEM_CATEG
BILLING_DATA_IN-REQ_QTY
BILLING_DATA_IN-SALES_UNIT
BILLING_DATA_IN-CURRENCY
If a material is billed for which a material master needs to be
determined (BILLING_DATA_IN-NO_MATMAST = ' '), you must make the
following entries :
BILLING_DATA_IN-PLANT
BILLING_DATA_IN-MATERIAL
If, on the other hand, a material is billed for which no material
master is to be determined (BILLING_DATA_IN_NO_MATMAST = 'X'), you
must make the following entries :
BILLING_DATA_IN-COUNTRY
BILLING_DATA_IN-MATERIAL
BILLING_DATA_IN-TAXCL_1MAT
pls reward if helpful.
cheers,
Hema. -
User-Exit for Checking Customer and Sale order type in Sales Order Creation
Hi Experts,
While creating the Sales Order once i enter sold-to-party and enter line item, i have to check the customer against the sales order type.
Please suggest me if any user-exit or enhancement or BADI available for it.
Thanks & Regards,
-VMHi
Follow the below steps to find out what all BADI's are called when you press any button in any transaction.
1) Goto se24 (Display class cl_exithandler)
2) Double click on the method GET_INSTANCE.
3) Put a break point at Line no.25 (CASE sy-subrc).
Now
4) Execute SAP standard transaction
5) Press the required button for which you need to write an exit logic, the execution will stop at the break point.
6) Check the values of variable 'exit_name', it will give you the BADI name called at that time.
7) This way you will find all the BADIs called on click of any button in any transaction.
mark if helpful
Regs,
Tushar Mundlik -
Need 3 column based on excel formulas, for Average cost of sales.
hii,,
i am using Oracle 10g...
select
pdate,
pcode,
pno,
pqty,
pprice,
trade_amt
, qty_on_hand
, total_cost
, case when pqty < 0
then
lag (avg_price) over (order by pdate)
else
avg_price
end avg_price
, case when pqty < 0
then
lag (avg_price) over (order by pdate)*-pqty
else
avg_price*pqty
end bal_cost
from (
select
pdate,
pcode,
pno,
pqty,
pprice,
pqty*pprice trade_amt,
sum (pqty) over (order by pdate) qty_on_hand,
sum (pqty*pprice) over (order by pdate) total_cost,
sum (pqty*pprice) over (order by pdate) /
sum (pqty) over (order by pdate) avg_price
from
select to_date('12/01/2011','dd/mm/yyyy') pdate, 'PUR' pcode, 1 pno, 10 pqty, 37.425 pprice from dual union all
select to_date('13/01/2011','dd/mm/yyyy'), 'INV', 1, -5, 48.169 from dual union all
select to_date('14/01/2011','dd/mm/yyyy'), 'PUR', 3, 15, 21.628 from dual union all
select to_date('15/01/2011','dd/mm/yyyy'), 'INV', 4, -10, 32.6 from dual union all
select to_date('16/01/2011','dd/mm/yyyy'), 'PUR', 4, 20, 22.33 from dual union all
select to_date('16/01/2011','dd/mm/yyyy'), 'PUR', 5, 35, 19.55 from dual union all
select to_date('18/01/2011','dd/mm/yyyy'), 'INV', 5, -8, 28 from dual union all
select to_date('22/01/2011','dd/mm/yyyy'), 'INV', 6, -12, 32.6 from dual
order BY 1,2,3
this is what the above query returns....( total_cost and avg.price are wrong...so as the bal_cost)
PDATE PCO PNO PQTY PPRICE TRADE_AMT QTY_ON_HAND TOTAL_COST AVG_PRICE BAL_COST
12-JAN-11 PUR 1.000 10.000 37.425 374.250 10.000 374.250 37.425 374.25
13-JAN-11 INV 1.000 -5.000 48.169 -240.845 5.000 133.405 37.425 187.125
14-JAN-11 PUR 3.000 15.000 21.628 324.420 20.000 457.825 22.891 343.373
15-JAN-11 INV 4.000 -10.000 32.600 -326.000 10.000 131.825 22.891 228.915
16-JAN-11 PUR 4.000 20.000 22.330 446.600 65.000 1262.675 19.426 388.517
16-JAN-11 PUR 5.000 35.000 19.550 684.250 65.000 1262.675 19.426 679.905
18-JAN-11 INV 5.000 -8.000 28.000 -224.000 57.000 1038.675 19.426 155.407
22-JAN-11 INV 6.000 -12.000 32.600 -391.200 45.000 647.475 18.222 218.669
8 rows selected.
i expect the result to be like this...
PDATE PCO PNO PQTY PPRICE TRADE_AMT QTY_ON_HAND TOTAL_COST AVG_PRICE BAL_COST
12-JAN-11 PUR 1.000 10.000 37.425 374.250 10.000 374.250 37.425 374.25
13-JAN-11 INV 1.000 -5.000 48.169 -240.845 5.000 133.405 37.425 187.125
14-JAN-11 PUR 3.000 15.000 21.628 324.420 20.000 457.825 25.577 511.545
15-JAN-11 INV 4.000 -10.000 32.600 -326.000 10.000 131.825 25.577 255.773
16-JAN-11 PUR 4.000 20.000 22.330 446.600 65.000 1262.675 23.412 702.373
16-JAN-11 PUR 5.000 35.000 19.550 684.250 65.000 1262.675 21.333 1386.623
18-JAN-11 INV 5.000 -8.000 28.000 -224.000 57.000 1038.675 21.333 1215.961
22-JAN-11 INV 6.000 -12.000 32.600 -391.200 45.000 647.475 21.333 959.969
8 rows selected.to arrive at bal_cost and avg.price, i need 1 more calculation for 'cost_of_sal' which is where i am stuck how to create it first and make use of that..
1) qty_on_hand running balance is OK..
2) cost_of_sale = when qty is -nve (i.e. pcode = 'INV') then take (1 row)previous value of Avg.Price and multiply by sold qty of current row.
3) bal_cost = when qty is +ve (i.e. pcode = 'PUR') then take (1 row)previous value bal_cost and add the trade_amt of current_row OR
when qty is -nve (i.e. pcode='INV') then take (1 row)previous vaue bal_cost and add the cost_of_sale of current_row
finally
4) avg.price = bal_cost / qty_on_hand
just a link showing excel forumlas...http://www.flickr.com/photos/58335021@N07/5356642176/
thank you..hii Etbin..thanks for your effort..but still the result is not as i want, above...
select pdate,pcode,pno,pqty,pprice,trade_amt,qty_on_hand,total_cost,avg_price,bal_cost,
case when pqty < 0
then lag(avg_price) over (order by pdate) * (- pqty)
end cost_of_sale, /* shown as an intermediate result - included in next case */
case when pqty < 0
then lag(bal_cost) over (order by pdate) + lag(avg_price) over (order by pdate) * (- pqty)
else lag(bal_cost) over (order by pdate) + trade_amt
end bal_cost_new, /* shown as an intermediate result - used in next case */
case when pqty < 0
then lag(bal_cost) over (order by pdate) + lag(avg_price) over (order by pdate) * (- pqty)
else lag(bal_cost) over (order by pdate) + trade_amt
end / qty_on_hand avg_price_new
from (select pdate,pcode,pno,pqty,pprice,trade_amt,qty_on_hand,total_cost,
case when pqty < 0
then lag(avg_price) over (order by pdate)
else avg_price
end avg_price,
case when pqty < 0
then lag(avg_price) over (order by pdate) * (- pqty)
else avg_price * pqty
end bal_cost
from (select pdate,pcode,pno,pqty,pprice,
pqty * pprice trade_amt,
sum(pqty) over (order by pdate) qty_on_hand,
sum(pqty * pprice) over (order by pdate) total_cost,
sum (pqty * pprice) over (order by pdate) / sum(pqty) over (order by pdate) avg_price
from
select to_date('12/01/2011','dd/mm/yyyy') pdate, 'PUR' pcode, 1 pno, 10 pqty, 37.425 pprice from dual union all
select to_date('13/01/2011','dd/mm/yyyy'), 'INV', 1, -5, 48.169 from dual union all
select to_date('14/01/2011','dd/mm/yyyy'), 'PUR', 3, 15, 21.628 from dual union all
select to_date('15/01/2011','dd/mm/yyyy'), 'INV', 4, -10, 32.6 from dual union all
select to_date('16/01/2011','dd/mm/yyyy'), 'PUR', 4, 20, 22.33 from dual union all
select to_date('16/01/2011','dd/mm/yyyy'), 'PUR', 5, 35, 19.55 from dual union all
select to_date('18/01/2011','dd/mm/yyyy'), 'INV', 5, -8, 28 from dual union all
select to_date('22/01/2011','dd/mm/yyyy'), 'INV', 6, -12, 32.6 from dual
order by 1,2,3
PDATE PCO PNO PQTY PPRICE TRADE_AMT QTY_ON_HAND TOTAL_COST AVG_PRICE BAL_COST COST_OF_SALE BAL_COST_NEW AVG_PRICE_NEW
12/01/2011 PUR 1.000 10.000 37.425 374.250 10.000 374.250 37.425 374.250
13/01/2011 INV 1.000 -5.000 48.169 -240.845 5.000 133.405 37.425 187.125 187.125 561.375 112.275
14/01/2011 PUR 3.000 15.000 21.628 324.420 20.000 457.825 22.891 343.369 511.545 25.577
15/01/2011 INV 4.000 -10.000 32.600 -326.000 10.000 131.825 22.891 228.913 228.913 572.281 57.228
16/01/2011 PUR 4.000 20.000 22.330 446.600 65.000 1262.675 19.426 388.515 675.513 10.393
16/01/2011 PUR 5.000 35.000 19.550 684.250 65.000 1262.675 19.426 679.902 1072.765 16.504
18/01/2011 INV 5.000 -8.000 28.000 -224.000 57.000 1038.675 19.426 155.406 155.406 835.308 14.655
22/01/2011 INV 6.000 -12.000 32.600 -391.200 45.000 647.475 18.222 218.668 233.109 388.515 8.634
8 rows selected.any other thought..
TY -
Descriptor query manager and custom PL/SQL call for the data update
hi all,
in the application, I'm currently working on, the operations for the data INSERT/UPDATE /DELETE are allowed only by means of PL/SQL function. Using the descriptor's query manager I'm trying to modify default behavior of TopLink and execute PL/SQL when there is a request to modify the data.
DescriptorQueryManager entityQueryManager = session.getClassDescriptor(MyEntity.class).getQueryManager();
StoredFunctionCall call = new StoredFunctionCall();
call.setUsesBinding(true);
call.setProcedureName("merge_record");
call.setResult("id", Integer.class);
call.addNamedArgument("cbic_id", "id"); // MyEntity.getId() – works!
call.addNamedArgument("publication_flag", "publicationFlag"); // MyEntity.getPublicationFlag () – works!
call.addNamedArgument("routing_id", "routing"); // MyEntity.getRouring() – works!
call.addNamedArgument("issue_id", "issue"); // MyEntity.getIssue() – works!
call.addNamedArgument("country_id", "country"); // MyEntity.getCountry() – works!
entityQueryManager.setInsertCall(call);
entityQueryManager.setUpdateCall(call);
entityQueryManager.setDeleteCall(call);
the problem:
when I call: MyEntity savedObject = (MyEntity) UnitOfWork.deepMergeClone(entity);
the binding doesn’t happen and I see following logs:
[TopLink Finest]: 2008.02.01 02:51:41.534--UnitOfWork(22937783)--Thread(Thread[AWT-EventQueue-0,6,main])--Merge clone xxx.Entity[id=2000]
[TopLink Warning]: 2008.02.01 02:51:41.550--ClientSession(8454539)--Thread(Thread[AWT-EventQueue-0,6,main])--Missing Query parameter for named argument: id null will be substituted. (There is no English translation for this message.)
[TopLink Warning]: 2008.02.01 02:51:41.550--ClientSession(8454539)--Thread(Thread[AWT-EventQueue-0,6,main])--Missing Query parameter for named argument: publicationFlag null will be substituted. (There is no English translation for this message.)
[TopLink Warning]: 2008.02.01 02:51:41.565--ClientSession(8454539)--Thread(Thread[AWT-EventQueue-0,6,main])--Missing Query parameter for named argument: routing null will be substituted. (There is no English translation for this message.)
[TopLink Warning]: 2008.02.01 02:51:41.565--ClientSession(8454539)--Thread(Thread[AWT-EventQueue-0,6,main])--Missing Query parameter for named argument: issue null will be substituted. (There is no English translation for this message.)
[TopLink Warning]: 2008.02.01 02:51:41.565--ClientSession(8454539)--Thread(Thread[AWT-EventQueue-0,6,main])--Missing Query parameter for named argument: country null will be substituted. (There is no English translation for this message.)
[TopLink Fine]: 2008.02.01 02:51:41.565--ClientSession(8454539)--Connection(6233000)--Thread(Thread[AWT-EventQueue-0,6,main])--BEGIN ? := merge_record(cbic_id=>?, publication_flag=>?, routing=>?, issue=>?, country=>?); END;
bind => [=> id, null, null, null, null, null] – WHY?
Calling straight forward the same PL/SQL block using:
DataModifyQuery updateQuery = new DataModifyQuery();
updateQuery.setCall(call);
updateQuery.shouldBindAllParameters();
and passing parameters as Vector works very well.
Could you please help me to fix the binding problem when I’m using the PL/SQL with Query Manager?
regards,Hello,
This is fairly common. Since the database is case insensitive (mostly) field names passed in don't really matter much. Unfortunately, java string comparisons are case sensitive, so if you db column for the getId() property is defined as uppercase "ID" it will not match to the lower case "id" defined in the
call.addNamedArgument("cbic_id", "id");
This will cause TopLink to get null when it looks for the "id" field in the row it builds from your MyEntity instance.
Matching the case exactly will resolve the issue.
Best Regards,
Chris -
Credit check for the first sales order
Friends,
We are using dynamic crdit check.
we set credit limit for Rs 100000. Now when I am creating first sales order for Rs. 500000, system allow to do it.
Practically it should not allow to do it. How to handle this? please help.
ThanksDear Pratap,
Enusre that in OVAK, you have the check credit as D and the credit group as 01.
The credit check will be either static or dyanmic based on which indicator you are choosing in the transaction OVA8.
Open order:Orders which are not delivered and relevant for credit check.
Open delivery: Delivery which is not invoiced and relevant for credit check.
Open billing doc: Invoice to which accounting document is not genereated yet in the system.
Open Items: Accounting documents which are due from the customer, and cleared in the system yet.
These are all the basic definitions to explain the difference between static and dynamic check.
The difference between the static and dynamic check is as below.
In case of static check, all the open order, open delivery, open billing document, opn item will be considered during the credit check.
In case of dynamic check, you will be specifying the HORIZON period which will restrict the open orders to be considered for a certain period.
That is to say, if you keep the HORIZON as 2 M, then the orders which are due for delivery beyond 2 months will be ignored; remaining open orders, open delivery, open billing document, open itms will be taken into consideration as it is.
If you don't use the HORIZON period, I would suggest you to activate the indicator STATIC rather than dynamic. Hope this clarifies.
Please do revert if need any more clarification.
thank you
Venkatesh SP -
What could be the query to get Spend Amount for a Product name in EBS?
Hi Experts,
I need a help to write a query in EBS to get Spend Amount for any given Product Name and Top Level Category (Segment1).
It can be two different query or a single one. Please reply if anyone knows how to do it. I need it for testing purpose.
Thanks in advance.All good here Sudipta.
You can try the below SQL.
SELECT msib.description,mcb.segment1,SUM(pla.quantity*pla.unit_price) total_spend
FROM
po_lines_all pla,
mtl_categories_b mcb,
mtl_system_items_b msib
WHERE pla.category_id = mcb.category_id
AND pla.item_id = msib.inventory_item_id
AND msib.organization_id = <enter your item master organization id>
GROUP BY msib.description,mcb.segment1
If you don't want to use the PO_LINES_ALL, is there any other sourced you are planning to use for spend.
SELECT mcb.segment1,SUM(pla.quantity*pla.unit_price) total_spend
FROM
po_lines_all pla,
mtl_categories_b mcb
WHERE pla.category_id = mcb.category_id
GROUP BY mcb.segment1
and do not need the po_lines_all table. I'm doing a data validation between OBIEE reports and EBS test data. In report i'm keeping only Product Name and Spend Amount to make it simple. Now I need to check the values are same in report and EBS. Thats the criteria.
Thanks
Sudipta -
Cost of Sales Amount more then Sales Amount
Hi All
We have an issue at a customer where the cost of sales amount is more then the Sales amount for the month of august...for the a specific customer group.
The account balances also reflect the same.
The customer uses Advance Gl account determination and managed Items by Item Group...where each item group as their own Stock, Sales and Cost of sales account...this is managed with the rules in the advanced GL determination.
We have ran the general ledger report to see if there are any peculiar transactions, but we cant seem to see anything out of the ordinary.
Is there anything else we can check to find out where the problem lies.
Any ideas are welcome.
Thank you.
JerushaHi Jerusha,
Run this query and check the last column grossprofit . If it's negative you have a negative profit and then see the document.
SELECT T1.[DocNum], T1.[DocDate], T0.[DocEntry], T0.[LineNum], T0.[ItemCode], T0.[Dscription], T0.[Quantity], T0.[TotalSumSy], T0.[GrssProfit] FROM INV1 T0 INNER JOIN OINV T1 ON T0.DocEntry = T1.DocEntry WHERE T1.[DocDate] >= [%0] and T1.[DocDate] <=[%1]
Regards,
Augusto -
How to generate mdx query using C#
I am new to mdx query and i am very curious about mdx query generation using c# so i searched for any demo or open source then i found
Ranet.olap, which is providing what i need. After taking the dlls i tried to incorporate them in my code. I am pasting my full
console code which should generate mdx query but it's not doing so, Am i doing something wrong.
using System;
using System.Collections.Generic;
using Microsoft.AnalysisServices.AdomdClient;
using Ranet.Olap.Core.Managers;
using Ranet.Olap.Core.Metadata;
using Ranet.Olap.Core.Types;
namespace MDX
class Program
static void Main(string[] args)
startWork();
public static void startWork()
string connString = "Provider=MSOLAP.3; Data Source=localhost;Initial Catalog=AdventureWorkDW2008R2;Integrated Security=SSPI;";
CubeDef cubes;
AdomdConnection conn = new AdomdConnection(connString);
conn.Open();
cubes = conn.Cubes.Find("AdventureWorkCube");
Ranet.Olap.Core.Managers.MdxQueryBuilder mdx = new Ranet.Olap.Core.Managers.MdxQueryBuilder();
mdx.Cube = cubes.Caption;
List<Ranet.Olap.Core.Wrappers.AreaItemWrapper> listColumn = new List<Ranet.Olap.Core.Wrappers.AreaItemWrapper>();
List<Ranet.Olap.Core.Wrappers.AreaItemWrapper> listRow = new List<Ranet.Olap.Core.Wrappers.AreaItemWrapper>();
List<Ranet.Olap.Core.Wrappers.AreaItemWrapper> listData = new List<Ranet.Olap.Core.Wrappers.AreaItemWrapper>();
//Column area
Dimension dmColumn = cubes.Dimensions.Find("Dim Product");
Microsoft.AnalysisServices.AdomdClient.Hierarchy hColumn = dmColumn.Hierarchies["English Product Name"];
//hierarchy properties
List<PropertyInfo> lPropInfo = new List<PropertyInfo>();
foreach (var prop in hColumn.Properties)
PropertyInfo p = new PropertyInfo();
p.Name = prop.Name;
p.Value = prop.Value;
lPropInfo.Add(p);
Ranet.Olap.Core.Wrappers.AreaItemWrapper areaIColumn = new Ranet.Olap.Core.Wrappers.AreaItemWrapper();
areaIColumn.AreaItemType = AreaItemWrapperType.Hierarchy_AreaItemWrapper;
areaIColumn.Caption = hColumn.Caption;
areaIColumn.CustomProperties = lPropInfo;
listColumn.Add(areaIColumn);
//Rows Area
Dimension dmRow = cubes.Dimensions.Find("Due Date");
Microsoft.AnalysisServices.AdomdClient.Hierarchy hRow = dmRow.Hierarchies["English Month Name"];
List<PropertyInfo> lRowPropInfo = new List<PropertyInfo>();
foreach (var prop in hRow.Properties)
PropertyInfo p = new PropertyInfo(prop.Name,prop.Value);
lRowPropInfo.Add(p);
Ranet.Olap.Core.Wrappers.AreaItemWrapper areaIRow = new Ranet.Olap.Core.Wrappers.AreaItemWrapper();
areaIRow.AreaItemType = AreaItemWrapperType.Hierarchy_AreaItemWrapper;
areaIRow.Caption = hRow.Caption;
areaIRow.CustomProperties = lRowPropInfo;
listRow.Add(areaIRow);
//Measure Area or Data Area
Measure ms = cubes.Measures.Find("Order Quantity");
Ranet.Olap.Core.Wrappers.AreaItemWrapper areaIData = new Ranet.Olap.Core.Wrappers.AreaItemWrapper();
areaIData.AreaItemType = AreaItemWrapperType.Measure_AreaItemWrapper;
areaIData.Caption = ms.Caption;
List<PropertyInfo> lmpropInfo = new List<PropertyInfo>();
foreach (var prop in ms.Properties)
PropertyInfo p = new PropertyInfo(prop.Name, prop.Value);
lmpropInfo.Add(p);
areaIData.CustomProperties = lmpropInfo;
listData.Add(areaIData);
mdx.AreaWrappersColumns = listColumn;
mdx.AreaWrappersRows = listRow;
mdx.AreaWrappersData = listData;
string mdxQuery = mdx.GenerateMdxQuery();
conn.Close();Hi mkm1,
According to your description, you want to use C# code to generate MDX Query. Right?
In Analysis Servcies, we just need to use "Microsoft.AnalysisServices.AdomdClient.dll" to open connection to SSAS database and retrieve data from cube. Here are some sample code about executing MDX query using C#.
Dim objConnection As New AdomdConnection("Data Source=localhost;Initial Catalog=Adventure Works DW 2008;")
Dim objCommand As New AdomdCommand()
Dim objDatatable As New DataTable
Dim strCommand As String
strCommand = "SELECT [Measures].[Internet Sales Amount] ON COLUMNS, "
strCommand = strCommand & " [Date].[Calendar].[Calendar Year] ON ROWS"
strCommand = strCommand & " FROM [Adventure Works]"
objConnection.Open()
objCommand.Connection = objConnection
objCommand.CommandText = strCommand
Dim objDataAdapter As New AdomdDataAdapter(objCommand)
objDataAdapter.Fill(objDatatable)
objConnection.Close()
Since your code is more related to a third party API, we suggest you post your question to Rnet.
Reference:
Microsoft.AnalysisServices.AdomdClient Namespace
If you have any question, please feel free to ask.
Simon Hou
TechNet Community Support -
How to load member for "sales same date last year"?
I need to load a member in Measures named "PriorYrSales" with "Sales" for the same date last year as today's date. Thus, retrieving "PriorYrSales" for 2/10/2002 would return the sales amount for 2/10/2001. Since days roll-up to months, quarters, years, it would be easy to determine how we're doing compared to the same time last year.Data is loaded each day for a date range from the current date and the preceding x days. Substitution variables are available for the beginning and ending date and the same dates for last year.For example: Data is loaded from beginning date of 2/01/2002 through ending date of 2/10/2002.The prior year date variables contain 2/01/2001 and 2/10/2001.The time period dimension is as follows:FY01->Jan2001-->01012001 (Alias: 1/01/2001)-->01022001 (Alias: 1/02/2001)-->all the dates in Jan->Feb2001-->02012001 (Alias: 2/01/2001)-->02022001 (Alias: 2/02/2001)-->all the dates in Febetc.FY02->Jan2002-->01012002 (Alias: 1/01/2002)-->01022002 (Alias: 1/02/2002)-->all the dates in Jan->Feb2002-->02012002 (Alias: 2/01/2002) -->02022002 (Alias: 2/01/2002)-->all the dates in Febetc.Thanks your any and all suggestions.Phil
Perhaps I wasn't clear in the first post. The intent is to easily compare sales for a current date/period to the same date/period last year. Neither Excel nor Analyzer provide a method that I'm aware of to retrieve data as follows:-------------------------------------Period Sales PriorYrSales Diff4/15/2002 1,000 900 100-------------------------------------(900 is sales for 4/15/2001)(100 is the calculated difference.)Nor can I do this:-------------------------------------Period Sales Period Sales Diff4/15/2002 1,000 4/15/2001 900 100-------------------------------------What Excel and Analyzer do allow is:-------------------------------------Period Sales 4/15/2002 1,0004/15/2001 900-------------------------------------I readily acknowledge that the data is redundant but I can't think of another option that will allow Excel and Analyzer to easily retrieve the values for comparison. If the PriorYrSales member can be loaded then the users can compare years, quarters, months and days quite easily.My challenge is knowing how use a calc script to derive prior year dates that correspond to current year dates. Something like:PriorYrSales->04152002 = Sales->04152001I've considered arrays but I've never used them and the documentation is not helpful enough for me.Thanks for your response.Phil
-
Sales Amount from one column of period (FY-2012, FY-2013) to 2 different columns
Hi dudes,
I'm having some difficulties in getting the Sales Amount from one column of period (Fiscal Year containing 2012 and 2013) and put it into 2 different columns (Sales 2012 and Sales 2013. I have 3 fields in my dataset: Sales (for all the years), Fiscal
Year (more than 5 years) and month (which I can neglect).
For the moment, my situation is as follows:
Fiscal Year Month
Sales
2012 Jan $72,500
Feb $80,200
Dec $79,500
2013 Jan $51,000
Feb $62,800
Dec $85,000
However I would like to get a scenario as follows:
Month
Sales 2012 Sales 2013
Jan $72,500 $51,000
Feb $80,200 $62,800
Dec $79,500 $85,000
Once I have this, I would be much easier for me to do the difference between the two sales period.
Is there any expression I can use?
I tried to filter from the Group properties the sales amount for Fiscal Year 2012 on 1 column, and on on another column, the sales amount for Fiscal Year 2013 but it is giving me the same values.
Thank you very much dudes.Hi Stan,
According to your description, we can use a matrix control to achieve your requirement. For more details, please refer to the following steps:
Drag a matrix from Toolbox to design surface.
Insert Month field to the first column.
Insert Fiscal_Year field to the first row of the second column.
Insert Sales field to the second row of the second column.
Right-click the second column to add a column with Outside Group-Right option.
Type the expression below to the second row of the third column:
=sum(iif(Fields!Fiscal_Year.Value=‘2012’,CDbl(Fields!Sales.Value),CDbl(0)))-sum(iif(Fields!Fiscal_Year.Value=‘2013’,CDbl(Fields!Sales.Value),CDbl(0)))
The following screenshot id for your reference:
If there are any other questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support
Maybe you are looking for
-
Itunes is installed on my computer, but it wont open...plz help!
I have itunes and quicktime on my computer, but when i click on the itunes icon, it computer seems to be opening the program, but then it stops and nothing happens, no error messages or anything. I have windows xp pro, service pack 2. If anyone can t
-
Error while running the code for watermarking
HI, I am using pdf proffesional and SDK for developing my application. At the time of watermarking I am getting below mentioned error. An unhandled exception of type 'System.MissingMemberException' occurred in microsoft.visualbasic.dll Additional inf
-
Open a file every time I launch an application.
I am wondering if there is a way to have a specific textedit file open automatically whenever I launch a certain application?
-
Does the time capsule work with a pc and a mac?
I need to know whether or not I can save pc and mac files at the same time, on a time capsule.
-
HI, How to Write Web Reports in SAP