I have two facts
I use the following code to load from QVD
Vente:
LOAD PrixUnitaireArticle,
PrixArticleHT,
PrixRevientTTC,
MargeHT,
MargeTTC,
ValeurRevientHT,
ValeurRevientTTC,
ValeurMargeHT,
ValeurMargeTTC,
PrixVenteHT,
FROM
E:\QVD TEST\VenteFULL.qvd
(qvd);
LOAD
[idObjCA]
,[CA TTC]
,[VAL MRG TTC]
,[CA HT]
,[VAL MRG HT]
,[Rayon]
, [Date Time Budget]
,[Code Site Budget]
,[Code Rayon]
FROM
E:\QVD TEST\Budget.qvd
(qvd)
When I load data , I got the following shema , there are too many loops .
How can I improve my data model ?
You can make a linktable which contains all the fields that are in double and then remove it from the source table.
You have to create key in each source table and put it in the linktable.
Here a example of a good linktable schema:
Related
in Tab1
details of PS1_VBRK table load is perfectly fine
in Tab5:
//ZBI0 - NAST
Left Join(PS1_VBRK)
PS1_NAST_ZBI0:
LOAD
ERDAT as ZBI0_Created_On,
ERUHR as ZBI0_Created_At,
KSCHL as ZBI0_Type,
OBJKY as Billing_doc,
VSTAT as ZBI0_Status
FROM
$(SAPPath_New)$(SAPPrefix_New)NAST.qvd
(qvd)
WHERE KSCHL = 'ZBI0';
RIGHT JOIN(PS1_NAST_ZBI0)
NoConcatenate
LOAD
MAX(ZBI0_Created_On) as ZBI0_Created_On,
MAX(ZBI0_Created_At) as ZBI0_Created_At,
ZBI0_Type,
Billing_doc
RESIDENT PS1_NAST_ZBI0
GROUP BY ZBI0_Type, Billing_doc;
Although you gave the table a name (PS1_NAST_ZBI0) Qlik will not produce such table, because you are also joining it to PS1_VBRK (Left Join(PS1_VBRK))
So technically table name PS1_NAST_ZBI0 never existed (as separate table) but it's data is part of PS1_VBRK
I've inherited a database from someone who has since left my office, and I'm having trouble correcting an issue that's come up with some of the data being pulled.
I've been able to narrow it down to the issue only being with the query that's used to pull data to aggregate how many entries there were for a business and the percentage of those entries.
Shown in this first two images, there is data for the General Returns and the NOC entries:
[NOC Entries]
[General Returns]
But when applying the same date range, no data comes up in the percentage calculation, when I believe there should be.
There are two query steps that make up how the percentage data is pulled. Step one pulls the following:
[Step 1]
But step 2 only pulls a very small part of the data:
[Step 2]
Here's the SQL Code for Part 1:
SELECT TBL_ACH_Customers.CUST_ACHName
, TBL_ACH_Returns_and_NOCs_Transactions.ACHReturns_Type
, COUNT(TBL_ACH_Returns_and_NOCs_Transactions.ACHReturns_Type) AS CountOfACHReturns_Type
FROM TBL_ACH_Returns_and_NOCs_Transactions
RIGHT JOIN TBL_ACH_Customers
ON TBL_ACH_Returns_and_NOCs_Transactions.CUST_ACHName = TBL_ACH_Customers.CUST_ACHName
WHERE (((TBL_ACH_Returns_and_NOCs_Transactions.ACHReturns_Date)
BETWEEN [Forms]![FRM_ACH_RPT_Return_Percentages]![startdate]
AND [Forms]![FRM_ACH_RPT_Return_Percentages]![enddate]))
GROUP BY TBL_ACH_Customers.CUST_ACHName
, TBL_ACH_Returns_and_NOCs_Transactions.ACHReturns_Type
ORDER BY TBL_ACH_Customers.CUST_ACHName;
And Part 2:
SELECT QRY_ACH_RPT_Return_Percentages_Step_1.CUST_ACHName
, QRY_ACH_RPT_Return_Percentages_Step_1.ACHReturns_Type
, QRY_ACH_RPT_Return_Percentages_Step_1.CountOfACHReturns_Type
, COUNT(TBL_ACH_Transactions.ACHTRAN_Amount) AS CountOfACHTRAN_Amount
, SUM(TBL_ACH_Transactions.ACHTRAN_NumEntries) AS SumOfACHTRAN_NumEntries
FROM TBL_ACH_Transactions
INNER JOIN QRY_ACH_RPT_Return_Percentages_Step_1
ON TBL_ACH_Transactions.CUST_ACHName = QRY_ACH_RPT_Return_Percentages_Step_1.CUST_ACHName
WHERE (((TBL_ACH_Transactions.ACHTRAN_EffectiveDate)
BETWEEN [Forms]![FRM_ACH_RPT_Return_Percentages]![startdate]
AND [Forms]![FRM_ACH_RPT_Return_Percentages]![enddate]))
GROUP BY QRY_ACH_RPT_Return_Percentages_Step_1.CUST_ACHName
, QRY_ACH_RPT_Return_Percentages_Step_1.ACHReturns_Type
, QRY_ACH_RPT_Return_Percentages_Step_1.CountOfACHReturns_Type;
Any help or guidance would be appreciated, and feel free to ask questions if you need more information!
I want to know which order position (EBELP from EKPO in SAP MM) appear in which G/L account (HKONT in BSEG in SAP FI with koart = 'S').
I'm working with SQL queries on a redshift database which has the tables copied from SAP.
which has the tables copied from SAP.
If you copied ALL the tables you can improve your query in a following manner.
There is a wonderful table EKBE which is order document history and resembles all order data from EKPO. It contains both order numbers and corresponding material document numbers
EKBE: MSEG:
BELNR -> MBLNR
GJAHR -> MJAHR
BUZEI -> ZEILE
This totally eliminates the need of MSEG/MKPF in your horrendous query. Probable SELECT can be following:
SELECT ekbe.ebeln, ekbe.ebelp, bseg.hkont
FROM ekbe
LEFT JOIN bkpf ON bkpf.mandt = ekbe.mandt AND left(bkpf.awkey,10) = ekbe.belnr AND right(left(bkpf.awkey,14),4) = ekbe.gjahr AND bkpf.awtyp = 'RMRP'
LEFT JOIN bseg ON bseg.mandt = bkpf.mandt AND bseg.bukrs = bkpf.bukrs AND bseg.gjahr = bkpf.gjahr AND bseg.belnr = bkpf.belnr
Note that field AWTYP should also be specified in JOIN, because any accounting doc can have many materials of different types in the year (AWKEY = <object number> + <year>).
Also, I do not appreciate the order you join the tables in your original SELECT. Usually source data table (EKPO in our case as we are searching account for each purchase order) is putted first and all others are joined to her.
But it is a matter of taste and also a matter of Redshift syntax which you knows better.
Okay, so I found an answer after a couple of days looking through forums and SAP tables column by column... since I am mainly interested in connecting order positions to G/L accounts, I was able to find them in EKKN which is directly linkable to EKPO. For some ebelp there are multiple sakto which is why we need "vproz" to be able to divide the EKPO-NETWR into the different sakto.
Going through all of it also made me shift my question from linking EKPO and BSEG to linking EKPO-EBELP and the G/L accounts. The BSEG-HKONT (with filter to BSEG-KOART = 'S') are also in EKKN-SAKTO.
SELECT ebeln, ebelp, netwr, sakto, vproz, vproz * netwr / 100 AS sakto_netwr
FROM ekpo
LEFT JOIN (
SELECT
mandt
,ebeln
,ebelp
,sakto
,SUM(vproz) as vproz
FROM ekkn
GROUP BY mandt, ebeln, ebelp, sakto
)
ekkn ON ekkn.mandt = ekpo.mandt AND ekkn.ebeln = ekpo.ebeln AND ekkn.ebelp = ekpo.ebelp
I am working in Oracle E-Business Suite.
Considering this field "CUSTOMER_SHIP_TO_NUMBER"
Oracle EBS Screenshot
I need to know the column and the table in the back-end database, from which the values of this field is getting populated.
I tried examining the Record History, and the data is being fetched from a View, namely the OE_Order_Lines_V. I tried searching through that view but couldn't figure it out. I need to know the actual location, namely the Table, where this data (CUSTOMER_SHIP_TO_NUMBER) is being stored.
You can use the below query to find the customer details.
SELECT hp.party_name "CUSTOMER_NAME",
hca.account_number "CUSTOMER_NUMBER",
csu.location "SHIP_TO_ORG_ID",hca.cust_account_id "CUSTOMER_ID"
FROM hz_parties hp, hz_cust_accounts hca,
hz_cust_acct_sites_all cas, hz_cust_site_uses_all csu
WHERE hp.party_id = hca.party_id
AND hca.party_site_id = cas.party_site_id
AND cas.cust_acct_site_id = csu.cust_acct_site_id
AND cas.address_type = 'SHIP_TO'
AND csu.location = <ship_to_org_id>;
The Data comes from the Table ONT.OE_ORDER_LINES_ALL, under the column of END_CUSTOMER_ID.
This should be joined with AR.RA_CUSTOMERS using the column CUSTOMER_ID to get the Customer Name and Number:
SELECT racust.customer_id
, racust.customer_name
, racust.customer_number -- this is the SHIP_TO_CUSTOMER_NUMBER
FROM AR.RA_CUSTOMERS racust
, ONT.OE_ORDER_headers_all oola
where oola.END_CUSTOMER_ID = racust.CUSTOMER_ID;
Read More Here: Oracle Order Management Technical Reference Manual
I have a field which is named: grupo it contains this values: Repairs & Maintenance . . . a lot of values I want to choose just the important thing and group all the other in autres: Other and calculate the total.
How can I do that in qlikview
I can advise you to make this in the script - create new field in the same table where grupo field is. The new field should be based on mapping table or something like this: if( match( grupo, 'ICMS','PENALTY' ) > 0, grupo, 'Other') as grupo1