Find customers IN, NOT IN from two transaction tables using DAX
I have two identical fact (sales) tables in Power Pivot. I need to classify customers in 3 categories.
Existing in both tables
Existing exclusively in table 1
Existing exclusively in table 2
What approach do I choose? UNION both the tables in model or keep them as separate tables? Also, what code is to be written to classify the customers in these 3 categories? I need to do Power View reporting on the categories - Distinct Customers, SalesAmt,
Sales Volume etc.
Thanks, Ashish Singh
Try these sollutions:
1.You can append both tables using Power Query ad-in. Even if a list of customers change in any of your tables you will not have to manually correct them in model. Refreshing Power Query table allow to have always updated data in model. Also if both tables
are differ but have a common column as "customers" that's enough to get appendable list of customers. Power Query allows to get distinct values without duplicates. Created table can be linked as a table to your Powerpivot model. No measures are nessesary.
You should receive a simple table with distinct customers names. Lets call it "List of all custumers"
To receive exclucive lists create relations between Table1 and Table2 using "List of all custumers". Now you can use all you need in one pivot table.
2. You can do the same without Power Querry but your data will not be autmaticaly refresh. Appendable table with customers list can be created manualy. This case also not require any formulas or measures.
Of course you can also try Greg's solution
Gordonik
Similar Messages
-
From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?
Hi,
Use NVL or COALESCE:
NVL (col_a, col_b)
Returns col_a if col_a is not NULL; otherwise, it returns col_b.
Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002 -
Lgical table from two physical table
Hi,
I am trying to design a logical fact table from two physical table. One table has transaction data and another has accounting data. The requirement is, I need to merge the rows between these two tables, where were it matches. If the keys are not matching between these two table then also I need to bring those rows from both tables as separate rows. How can i do this? Also can i have a logical table as source for my fact table.You'll need outer joins in your physical layer and you can drag the columns from both physical tables to a single logical table and you will see in the BMM layer it will create the two logical table sources.
-
How to create a foreign key for the table from two different tables?
Hi All,
I have a three table like below. In the below table SAMPLE_CONS_CHECK and SAMPLE_CONS2_CHECK will be having the primary key for NAME column. The same SAMPLE_CONS3_CHECK table also having the primary key for NAME column and forieign key for SAMPLE_CONS_CHECK and SAMPLE_CONS2_CHECK tables. See the below code 2
code 1:
CREATE TABLE SAMPLE_CONS_CHECK
(NAME VARCHAR2(10),
SERIES VARCHAR2(5)
CREATE TABLE SAMPLE_CONS2_CHECK
(NAME VARCHAR2(5),
MODEL NUMBER
CREATE TABLE SAMPLE_CONS3_CHECK
(NAME VARCHAR2(5),
MODEL_NO NUMBER
)code 2
alter table SAMPLE_CONS_CHECK
add constraint SAMPLE_CONS_CHECK_pk primary key (NAME)
alter table SAMPLE_CONS2_CHECK
add constraint SAMPLE_CONS2_CHECK_pk primary key (NAME)
alter table SAMPLE_CONS3_CHECK
add constraint SAMPLE_CONS3_CHECK_pk primary key (NAME)
ALTER TABLE SAMPLE_CONS3_CHECK ADD
CONSTRAINT SAMPLE_CONS3_CHECK_FK1 FOREIGN KEY
NAME
) REFERENCES SAMPLE_CONS_CHECK
NAME
) ON DELETE CASCADE;
ALTER TABLE SAMPLE_CONS3_CHECK ADD
CONSTRAINT SAMPLE_CONS3_CHECK_FK2 FOREIGN KEY
NAME
) REFERENCES SAMPLE_CONS2_CHECK
NAME
) ON DELETE CASCADE;From the above schenario i am able to insert the data to SAMPLE_CONS3_CHECK table. But the parent data is already available in the parent table. The problem is here two different constarints from two different tables. While inserting, it is checking from both the tables whether the parent is exist or not.
How can i solve this problem? Can anyone halp me about this?
Thanks
Edited by: orasuriya on Aug 8, 2009 2:02 AMActually the design is completely incorrect.
What you say is
I have
'foo', 'foo series'
'foo','foo model'
'foo',666
By virtue of table3 referring to both table1 and table2.
This means you actually need to have 1 (one) table:
'foo','foo series','foo model', 666
And the 'problem' disappears.
Sybrand Bakker
Senior Oracle DBA -
OBIEE 11g - Combine data from two Oracle tables
Good day!
I tried to combine data from two Oracle tables as fact data, but it doesn't work.
My steps: I created SCOTT.EMP2 table from SCOTT.EMP table, update EMPNO and ENAME values of EMP2 table to distinguish data of my tables. Then I imported physical tables DEPT, EMP and EMP2 to BIEE 11g, created joins DEPT-EMP and DEPT-EMP2 in physical diagram. Then I dragged DEPT and EMP tables to BMM, and EMP2 table to EMP as second LTS. In Content tab for EMP and EMP2 I checked "This source should be combined with other sources at this level" checkboxes. Then I renamed logical tables EMP and DEPT to Employees and Departments and dragged them to Presentation area. In Answers I created Analysis with columns DNAME and ENAME.
The problem is that data on results tab is only from one physical table EMP or EMP2 (depending on the order of sources EMP and EMP2 of LT Employees) and not from both.
Can anybody help? Am I missed something?
Al.Hi Al,
I think you have to define the content of the LTS.
http://download.oracle.com/docs/cd/E12096_01/books/admintool/admintool_BusModSetup16.html
You have to specify the content of the different fragments.
http://download.oracle.com/docs/cd/E12096_01/books/admintool/admintool_SetUpAggNav3.html#wp1005333
Maybe you have to add an additional column 'Source' ('EMP1', 'EMP2')
Good Luck,
Daan Bakboord
http://obibb.wordpress.com -
Selecting data from two different tables.
Do we need to use join two tables with primary/foreign key while trying to use select statement for getting data from those to table.? If no who can i go about do it.
872959 wrote:
If i am using From clause to get data from two different tables, is it necessary that both tables have column of identical data in them.In general, they ought to (or you need to join in a third table that tells you how to map rows from one table to rows of the other table).
It is not strictly necessary that there be any join condition between tables. If you don't provide a join condition, Oracle has to do a Cartesian product. That means that if there are n rows in one table and m rows in the other, the result set will have n * m rows. It is very rarely a good idea to write queries that do Cartesian products but it does occasionally happen.
Justin -
Leading zeros are not carried from the pivot table to exported Excel (9927815)
Hello All -
I am just wondering if there is a fix available for -- Leading zeros are not carried from the pivot table to exported Excel (9927815)
can anybody suggest when it will be fixed and if there is any-workaround for this issue if there is no fix available.
Thanks
RamThanks Timo -
Studio Edition Version 11.1.1.2.0
About
Oracle JDeveloper 11g Release 1 11.1.1.2.0
Studio Edition Version 11.1.1.2.0
Build JDEVADF_11.1.1.2.0_GENERIC_091029.2229.5536
Copyright © 1997, 2009 Oracle and/or its affiliates. All rights reserved.
IDE Version: 11.1.1.2.36.55.36
Product ID: oracle.jdeveloper
Product Version: 11.1.1.2.36.55.36
I will check on support.oracle.com -
Get the Common from Two Internal Tables with same structure
Hi ,
I need to get the Common data from Two Internal Tables with same structure with using the looping method.
For e.g.
I have two internal table say ITAB1 and ITAB2.
ITAB1 has values A,B,C,D,E,F
ITAB2 has values A,H,B,Y,O
Output at runtime should be : A,BHi mohit,
1. If u want to compare all fields,
for matching purpose,
then we can do like this.
2.
report abc.
data : a like t001 occurs 0 with header line.
data : b like t001 occurs 0 with header line.
loop at a.
LOOP AT B.
IF A = B.
WRITE :/ 'SAME'.
ENDIF.
endloop.
ENDLOOP.
regards,
amit m. -
Can we get the data from two internal tables in ALV.
hi friends i would like to display the data using two internal tables using alv grid.please guide me.
Hi,
ALV would be having a specific layout say :
MATNR
MAKTX
QTY
Now, if you have two internal tables, then do they have a different structure. If they have different structures, then what kind of ALV layout you expect. The ALV output should be as per the structure of 1st or 2nd internal table.
If both internal table have same layout, then populate the data from 2nd internal table into 1st internal table and pass the 1st internal table ( it will have data of both internal tables) to ALV.
Best regards,
Prashant -
Sum two different columns from two different tables
Can you select and sum two different columns, from two different tables in the same sql statement?
i.e.
table1
Item----OnHand_Qty
A--------10
A--------15
B--------10
B--------10
C--------20
table2
Item----Trx_Qty
A--------2
A--------4
A--------6
B--------1
B--------1
C--------4
I'm looking for the following results from a query
Item----Sum(Onhand_Qty)---Sum(Trx_Qty)
A--------25Like this?
SQL> create table table1 (item,onhand_qty)
2 as
3 select 'A', 10 from dual union all
4 select 'A', 15 from dual union all
5 select 'B', 10 from dual union all
6 select 'B', 10 from dual union all
7 select 'C', 20 from dual union all
8 select 'D', 30 from dual
9 /
Tabel is aangemaakt.
SQL> create table table2 (item, trx_qty)
2 as
3 select 'A', 2 from dual union all
4 select 'A', 4 from dual union all
5 select 'A', 6 from dual union all
6 select 'B', 1 from dual union all
7 select 'B', 1 from dual union all
8 select 'C', 4 from dual union all
9 select 'E', 3 from dual
10 /
Tabel is aangemaakt.
SQL> select nvl(t1.item,t2.item) item
2 , t1.sum_onhand_qty
3 , t2.sum_trx_qty
4 from ( select item, sum(onhand_qty) sum_onhand_qty
5 from table1
6 group by item
7 ) t1
8 full outer join
9 ( select item, sum(trx_qty) sum_trx_qty
10 from table2
11 group by item
12 ) t2
13 on (t1.item = t2.item)
14 /
I SUM_ONHAND_QTY SUM_TRX_QTY
A 25 12
B 20 2
C 20 4
E 3
D 30
5 rijen zijn geselecteerd.Regards,
Rob. -
Hi Friends,
I am using Oracle 8.1.6 Server, & facing problems while retrieving data from a PL/SQL Table:
CREATE or REPLACE PROCEDURE test_proc IS
TYPE tP2 is TABLE of varchar2(10); --declared a collection
dt2 tP2 := tP2('a','b','c');
i NUMBER(8);
begin
SELECT COUNT(*) INTO i FROM TABLE(CAST(dt2 as tP2));
DBMS_OUTPUT.PUT_LINE('**'||i);
end;
While executing the above procedure, I encountered foll. error:
ERROR at line 1:
ORA-00600: internal error code, arguments: [15419], [severe error during PL/SQL execution], [], [],
ORA-06544: PL/SQL: internal error, arguments: [pfrrun.c:pfrbnd1()], [], [], [], [], [], [], []
ORA-06553: PLS-801: internal error [0]
Can anyone please help me, where the problem is??
Is it Possible to retrieve data from PL/SQL TABLE using SELECT statement? & How ?
Thanks in advance.
Best Regards,
Jay Raval.Thanks Roger for the Update.
It means that have to first CREATE TYPE .. TABLE in database then only I can fire a Select statement on that TYPE.
Actually I wanted to fire a Select statement on the TABLE TYPE, defined & declared in PLSQL stored procedure using DECLARE TYPE .. TABLE & not using CREATE TYPE .. TABLE.
I was eager to know this, because my organization is reluctant in using CREATE TYPE .. TABLE defined in the database, so I was looking out for another alternative to access PL/SQL TABLE using Select statement without defining it database. It would have been good if I could access a PLSQL TABLE using Select statement Declared locally in the stored procedure.
Can I summarize that to access a PL/SQL TABLE using SELECT statement, I have to first CREATE TYPE .. TABLE?
If someone have any other idea on this, please do let me know.
Thanks a lot for all help.
Best Regards,
Jay Raval.
You have to define a database type...
create type tP2 is table of varchar2(10)
CREATE OR REPLACE PROCEDURE TEST_PROC
IS
dt2 tP2 := tP2('a','b','c');
i NUMBER(8);
begin
SELECT COUNT(*) INTO i FROM TABLE(CAST (dt2 AS tP2));
DBMS_OUTPUT.PUT_LINE('**'||i);
end;
This will work.
Roger -
Export the data with Alias from the alternative table using ODI
Hi!
How to export the data from Essbase with Alias from the alternative table using ODI?
Thanks.Are you on 10.1.3.6.x? Then: http://john-goodwin.blogspot.com/2008/09/odi-series-part-2-agent.html
Are you on 11g? Then: http://john-goodwin.blogspot.com/2010/12/managing-odi-11g-standalone-agents.html
I will say with only a mild amount of shame and a large amount of gratitude that I installed both releases' agents through John's blog posts.
Regards,
Cameron Lackpour
Edited by: CL on Jun 4, 2012 5:48 PM
Whoops, had the same link in there twice. -
Find smartform error - not printing from transaction
Hi
I have a little problem with a smartform .. that I don't know which is .. this because when I try the print from SMARTFORMS transaction, it works, for some data works correctly and for some other data, the print is not shown. I think there is an error in that case (functional guys told me it's mine problem) but I don't know ho w to get the error message that occurred. can anybody help me please?
I tried to search the forum before posting, because I think there should be a way for analyzing this kind of error, but probably I used wrong words, because I cannot find anything .. so sorry if the question has already been asked and answered (I hope)
thanks
gabrieleHi Gabriele,
It is hard to give an answer which solves your problem.
In most cases as the smartform sometimes with different forms the cause is that 1 or more fields are overfilled.
Like a too long variable in a to small field.
You must try to find out in which part of the smartform the problem occurs. One of the ways to do that is to shriinken the output part by part (with (output-)conditions) until you get a printed output. Then the problem is in the lastpart you have out-conditioned.
I know it is not an easy job but for error finding iin smartforms is hard.
success
Gr., Frank -
Confirmed Dimensions. OBIEE Not able to pull data from two fact tables.
Hi Experts,
I have a very simple set up of Star Schema with two fact tables and 1 dimension. Both fact tables joined to the dimension at the same level.
When i pull a column from both fact tables and the dimension table in OBIEE, it has to create simple SQL like below:
select FACT1.column1,
Fact2.Column1,
Dim.Column1
from FACT1, FACT2, DIM
where FACT1.ID = DIM.ID and FACT2.ID = DIM.ID
but instead it creating a query in a very complex way:
select case when D1.c2 is not null then D1.c2 when D2.c2 is not null then D2.c2 end as c2,
D1.c1 as c3,
D2.c1 as c4
from
(select FACT1.Column1 as c1,
DIM.Column1 as c2
from
DIM T1287863,
FACT1 T1287945
where (DIM.ID = FACT1.ID)
) D1 full outer join (
select FACT2.Column1 as c1,
DIM.Column1 as c2
from
DIM,
FACT2
where ( DIM.ID = FACT2.ID)
) D2 On isnull(D1.c2 , '1') = isnull(D2.c2 , '1') and isnull(D1.c2 , '2') = isnull(D2.c2 , '2')
I even tried setting the levels for both the fact tables and it still creates the query in avove way. Any thoughts on this will be vary helpful.Subramanian,
see below the code we're using for the RFM.
on the ct_containers table i'm passing a line, and its getting updated after the call.
on the ct_errors table i just want to receive the errors and i only receive the line, we add manually there ('Serious error with validation code').
kr, achim
FUNCTION zbapi_ra_validations .
*"*"Local Interface:
*" IMPORTING
*" VALUE(IS_RA_SCREEN) TYPE ZBAPI_S_RA_SCREEN
*" CHANGING
*" VALUE(CT_ERRORS) TYPE ZRA_T_ERRORS
*" VALUE(CT_CONTAINERS) TYPE ZRA_T_CONT_IP
DATA:
lo_badi_handle TYPE REF TO zra_validation_rule,
ls_error TYPE zra_s_error.
GET BADI lo_badi_handle.
TRY.
CALL BADI lo_badi_handle->validate_rules
EXPORTING
is_screen_flds = is_ra_screen
CHANGING
ct_containers = ct_containers
ct_errors = ct_errors.
CATCH zcx_ra.
ls_error-message = 'Serious error with validation code'.
APPEND ls_error TO ct_errors.
ENDTRY.
ENDFUNCTION.
if i call this rfm in SE37 the ct_errors table is populated with all errors and the manually created line.
Message was edited by: Achim Hauck -
Hi All,
I have to find out all the Domains which are related to Only Transaction Tables, that Domains should not be used or related to Master Tables, pls let me know is there any way to find out?
Akshitha.Step 1:
Select TABNAME from DD09L where TABART = 'APPL1'.
Select DOMNAME from DD03L where TABNAME = TABNAME (got from the above statement)
By this way you will get all the domains used in Transaction table
Step 2:
Select TABNAME from DD09L where TABART = 'APPL0'.
Select DOMNAME from DD03L where TABNAME = TABNAME (got from the above statement)
By this way you will get all the domains used in Master table
Step 3:
Display all the domains got from step 1 and not in step 2.
Hopefully this will fulfill your requirement.
Please reward if useful..
-Tushar
Maybe you are looking for
-
In which place the MDM Iviews resides in portal
help me understand the MDM Java architecture and In which place the MDM Iviews resides in portal. Can any one Help me on this
-
Unable To Sync After Migrating From Win XP(32 bit) to Win 7(64bit)
I received a new PC, dual core platform, for XMAS. However, I received a Com 1 port failure when performing a Hot Synch to upload my PD(,M500) data to Palm Desktop on the new PC. Palm tech support said there is no USB driver available for the 64 bi
-
Help ! I have just changed my iTunes' region to Thailand as local ( I'm from Australia n currently working here) n updated with my credit card acquired from Thailand too but every time when I try to make an in app purchase then it shows a message sa
-
If I get info on my library I see under sharing and permissions a user called fetching and a user called wheel. I am not familiar with these users. Are they there for a reason?
-
Hi, I'm currently working on a solution to deploy my fat image via USB to our Windows 8.1 devices. Some of the veterans here have tinkered with processes to deploy swm files, and it worked for me in the past. Unfortunately, the Keith Gardner process