Create a fact table from two Dim Tables - is it possible in powerpivot?

I have two comma delimited flat files.
1 - Customer Details (customerCode, Name, Address etc)
2 - Order Details(OrderNumber, OrderLineNumber, CustomerCode etc)
The two link by CustomerCode. I can bring both into powerpivot and link them directly, so cna deliver a report quickly. This model will grow however, with product dimension, store dimension and a few others.
So, i want to design it correctly from the outset, having a DimCustomer & a DimOrderDetail, that both link via a FactTable. I cant figure out how to create a factTable using both Dimensions using only powerPivot & dax. Is it possible?

Shaping the data before it gets to PowerPivot using Power Query is the easier option:
http://office.microsoft.com/en-us/excel-help/introduction-to-microsoft-power-query-for-excel-HA104003940.aspx
http://www.microsoft.com/en-us/download/details.aspx?id=39379
Ideally, with Power Pivot, the best model is a star schema where you have a single fact table and all the dimensions are linked directly to the fact table and not to one another.  This isn't always possible in real world modeling but it is definitely the
easiest to deal with when writing measures and designing pivots.  It also generally gives the best performance.

Similar Messages

  • 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 AM

    Actually 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

  • Modifying one table from two internal tables

    Hi All,
    I am a having a basic alv list records with check boxes .
    For Example in the Basic list  :
    WH         Rectyp     Count List No         Docmnt no       Count No.        Status No  Blocking Reason Code
    012        CC             0001                      0000000001          001                   13              A
    When I select the check box for the above record and click on a push button "Recount'.
    system has to  create a new record in the database table (ex:/tdit/sc_workltu) with the same record details but by incrementing  Count No by 1  and it has to change the status to 10 .After creating a new record it has to update the original record with the status 14 instead of 13 . as shown below
                 WH         Rectyp     Count List No         Docmnt no       Count No.        Status No  Blocking Reason Code
    Orig       012        CC             0001                      0000000001          001                   13              A
    New      012        CC             0001                      0000000001          002                   10              A
    Updorg  012        CC             0001                      0000000001          001                   14              A
    I had written the code but I am unable to create a new with all  field data it is only updating the status with 10 and remainig fields are getting empty .
    like
                 WH         Rectyp     Count List No         Docmnt no       Count No.        Status No  Blocking Reason Code
    New                                                                                10             
    Updorg  012        CC             0001                      0000000001          001                   14              A
    My Code :
    DATA: lt_tasks TYPE STANDARD TABLE OF zrf2_tasks,
            ls_tasks LIKE LINE OF lt_tasks,
            lt_new   TYPE STANDARD TABLE OF /tdit/sc_workltu,
            ls_new   LIKE LINE OF lt_new,
            lt_orig   TYPE STANDARD TABLE OF /tdit/sc_workltu,
            ls_orig   LIKE LINE OF lt_orig.
      LOOP AT gt_final INTO ls_final WHERE check_box EQ 'X' .
        IF ls_final-status EQ '13' .
    Increase the count number by 1
          ls_new = ls_final.
          ls_new-counum = ls_final-counum  + 1.
          ls_new-status = '10'.
          APPEND ls_new TO lt_new.
          CLEAR ls_new.
    MODIFY /tdit/sc_workltu FROM table lt_new.
    update original task to status 14
          ls_orig = ls_new = ls_final.
          ls_orig-belnum = ls_final-belnum.
          ls_orig-status = '14'.
          APPEND ls_orig TO lt_orig.
          CLEAR ls_orig.
    *Determine input parameters for walksequence
          ls_tasks-belnum = ls_final-belnum.
          ls_tasks-wzone = ls_final-wzone.
          ls_tasks-lgnum = ls_final-lgnum.
          SELECT SINGLE reihf
                FROM lagp
                INTO ls_tasks-reihf
                WHERE lgnum = ls_final-lgnum.
          APPEND ls_tasks TO lt_tasks.
          CLEAR ls_tasks.
        ELSE.
          IF ls_final-status = '10' OR
             ls_final-status = '11' OR
             ls_final-status = '12' OR
             ls_final-status = '16' OR
             ls_final-status = '17'.
             ls_tasks-belnum = ls_final-belnum.
             ls_tasks-wzone  = ls_final-wzone.
             ls_tasks-lgnum  = ls_final-lgnum.
            SELECT SINGLE reihf
                   FROM lagp
                   INTO ls_tasks-reihf
                   WHERE lgnum = ls_final-lgnum.
            APPEND ls_tasks TO lt_tasks.
            CLEAR ls_tasks.
          ENDIF.
        ENDIF.
      ENDLOOP.
      MODIFY /tdit/sc_workltu FROM table lt_orig.
      MODIFY /tdit/sc_workltu FROM table lt_new.
    Please verify the code and provide me the solution
    << Moderator message - Everyone's problem is important. But the answers in the forum are provided by volunteers. Please do not ask for help quickly. >>
    Thank you .
    Regards,
    Bharat Kumar
    Edited by: Rob Burbank on Jul 14, 2011 10:44 AM

    Hi Mrinmoy,
    No Key field has been changed .
    System has to create a new records with status 10  by incrementing the countno by 1 and update the table  and update the original record with status 14 .
    Thank you .
    Regards,
    Bharat

  • Populating one Internal table from two internal tables.

    Hello Gurus,
    iam having 3 internal table with same structure ,
    1st internal table having some records
    2nd internal table is also having some records
    what i need to do is to populate the records to the 3rd internal table which the common records in the 1st and 2nd internal table. (common means intersection).
    please explain how and using which concept and if possible code also...
    Regards,
    Ravi.

    hi ravi,
    look at the folowing code for reference
    *&--mard structure
    types: begin of struc_mard,
           matnr     type matnr,           "Material Number
           werks     type werks_d,           "Plant
           lgort     type lgort_d,           "Storage Location
           labst type labst,         "Valuated stock with unrestricted use
           end of struc_mard.
    *&--mara structure
    types: begin of struc_mara,
           matnr type matnr,         "material number
           meins type meins,         "unit of measurement
           mtart type mtart,         "material type
           ersda     type ersda,           "Creation date
           end of struc_mara.
    *&--maktx structure
    types: begin of struc_maktx,
           matnr type matnr,        "material number
           maktx type maktx,        "material description
           end of struc_maktx.
    *&--Final structure
    types: begin of struc_final,
           matnr     type matnr,           "Material Number
           werks     type werks_d,           "Plant
           lgort     type lgort_d,           "Storage Location
           labst type labst,         "Valuated stock with unrestricted use
           meins type meins,         "unit of measurement
           mtart type mtart,         "material type
           ersda     type ersda,           "Creation date
           maktx type maktx,         "material description
           v_box(1) type c,          "for checkbox field
           end of struc_final.
    *&---work  area for Internal Tables[population 1]
    data: wa_mard type struc_mard,
          wa_mara type struc_mara,
          wa_maktx type struc_maktx,
          wa_final type struc_final.
                     INTERNAL TABLES  DECLARATION                        *
    *&---Internal tables for storing data.[populaiton 1]
    data: i_mard  type standard table of struc_mard,
          i_mara  type standard table of struc_mara,
          i_maktx type standard table of struc_maktx,
          i_final type standard table of struc_final.
    *&--fetching the data from table for storage
      select  matnr
              werks
              lgort
              labst
              into table i_mard
              from mard
              where matnr in r_matnr and werks in r_werks and lgort in
              r_lgort
      if sy-subrc <> 0.  "if unsuccesful
        message e004.    "Error- Record does not exist
      endif.
    selection of material description
      if i_mard[] is not initial.
    *SELECT DISTINCT FOR UNIQUE ENTRIES ONLY
        select  distinct matnr
                         maktx
                         into table i_maktx
                         from makt
                         for all entries in i_mard
                         where matnr = i_mard-matnr and
                         spras = sy-langu.
        if sy-subrc <> 0.                    " if unsucessful
          wa_maktx-maktx = text-028.         "NO DESCRIPTION
        endif.
    *fetching information from material master
        select  distinct matnr
                         meins
                         mtart
                         ersda
                         into table i_mara
                         from mara for all entries in i_mard
                         where matnr = i_mard-matnr.
        if sy-subrc <> 0.
          message e003.
        endif.
    *&--sorting the tables
        sort: i_mard by matnr werks lgort,
              i_mara by matnr,
              i_maktx by matnr.
    *&--Clearing workareas.
        clear: wa_mard,
               wa_mara,
               wa_maktx,
               wa_final.
    *PROCESSING
        loop at i_mard into wa_mard.
    *moving values to final workarea
          wa_final = wa_mard.
          at new matnr.
            read table i_maktx into wa_maktx
            with key matnr = wa_mard-matnr binary search.
            read table i_mara into wa_mara
            with key matnr = wa_mard-matnr binary search.
          endat.
          if sy-subrc = 0.
            "if succesful then move to final workarea
            wa_final-maktx  = wa_maktx-maktx.
    *for mara values
            wa_final-meins  = wa_mara-meins.
            wa_final-mtart = wa_mara-mtart.
            wa_final-ersda  = wa_mara-ersda.
          endif.
    *append final workarea
          append wa_final to i_final.
        endloop.
    clearing and refreshing the table I_MARD
        refresh: i_mard.
        clear: wa_mard.
      endif.
    endform.                    "zf_populate_info
    this will move all the data into final table you have got, with the performnce tuned way
    reward point if useful
    Rohan malik

  • 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

  • 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)?

    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

  • How to create a table from an existing table with new column

    Hi !
    Please help me.
    I want to create a table from an existing table with data and add two new column to the new table.
    What will be the syntax?

    craete table new_table as select a.*, 'somevalue' new_col1, 'somevalue'
    new_col2 from old_table a;Also there is a pitfall - newly created table will accept column type and precision from the select statement, so further you can be needed to modify columns
    if you want to have VARCHAR2 instead of CHAR for example:
    SQL> create table new_dept as select dept.*, 'New data' new_col from dept;
    Table created.
    SQL> desc new_dept
    Name                                      Null?    Type
    DEPTNO                                             NUMBER(2)
    DNAME                                              VARCHAR2(14)
    LOC                                                VARCHAR2(13)
    NEW_COL                                            CHAR(8)
    SQL> alter table new_dept modify (new_col varchar2(8));
    Table altered.
    SQL> desc new_dept
    Name                                      Null?    Type
    DEPTNO                                             NUMBER(2)
    DNAME                                              VARCHAR2(14)
    LOC                                                VARCHAR2(13)
    NEW_COL                                            VARCHAR2(8)Rgds.
    Didn't see michael's post - it reflects the fix for this problem using CAST.
    Message was edited by:
    dnikiforov

  • How to design universe with tables from two databases using a db link?

    I am building a universe (v3.1) that has tables from two different oracle db instances.  My dba created synonyms for me and there is a database link in place.  I don't know how to get this working in Designer.  I can see the views under my ID when I browse to insert a table, but there is no structure.  I think I have to create a new strategy.  I attempted to do that, but the directions aren't very clear to me, and it isn't working.  Any help or advice would be greatly appreciated.  Thanks!!

    i've been working with DB links much before, but this was since long time ago before i join the Business Intelligence field
    from my understanding that you Have link from DB1 to DB2
    and from your user in DB1 you can access tables and view from DB2
    if you are using your user to create a universe im not sure if you can use tables from DB2 or not
    and you dont see the tables of the link in the Universe
    but you can try to create a drived table selecting from any tables from DB2
    for example
    select id,name from user.table2@mylink
    check this way and give me your feedback
    good luck

  • 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--------25

    Like 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.

  • Can we create a hierarchy based on two logical table in 10g RPD

    Hi,
    I have a question, please give me some clarity, about creating hierarchy,
    I know we can create a hierarchy based on one logical table which is form by two physical table...
    Can we create a hierarchy based on two logical table? If yes, and how?
    Thanks in advance!
    anne

    Use preffered drill paths...
    -suman

  • 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,B

    Hi 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.

  • Insert data into fact table from source database tables

    here i try to insert data into fact table from source database tables here is the query 
    ALTER procedure [dbo].[facttable]
    as
    insert into [pp dw].dbo.Dimfact(Prod_ID,Production_ID,Material_ID,Equip_ID,WC_ID,Recipe_ID,Quantity,costprice)
    select Products.[Product ID],[Production ID],Materials.[Material ID],[Equipment ID],[Work Centre ID],[Recipy ID],Quantity,[cost price]
    from
    [PRODUCTION PLANNING 2].dbo.[Products],
    [PRODUCTION PLANNING 2].dbo.[Production Detail],
    [PRODUCTION PLANNING 2].dbo.[Material category],
    [PRODUCTION PLANNING 2].dbo.[Materials],
    [PRODUCTION PLANNING 2].dbo.[Equipment],
    [PRODUCTION PLANNING 2].dbo.[Working Centre] ,
    [PRODUCTION PLANNING 2].dbo.[Recipies]
    where
    Products.[Product ID] in (13, 14, 15, 16, 17) and
    [Production Detail].[Production ID] in (1, 2, 3) and
    [Materials].[Material ID] in (1, 2, 3, 4, 5) and
    [Equipment].[Equipment ID] in (1, 2, 3, 4) and
    [Working Centre].[Work Centre ID] in (1, 2, 3) and
    [Recipies].[Recipy ID] in (1, 2, 3) and
    [Material category].[Category ID] in (8, 9, 10, 11, 12, 13)
    and when i execute query it shows me error 
    The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Dimfact_Dimproduct". The conflict occurred in database "pp dw", table "dbo.Dimproduct", column 'Prod_ID'.
    ERD IS
    HOW TO SOLVE THIS PROBLEM?

    I cant see any join conditions in your query posted. Whats the purpose of the query above. It will just bring you a cartesian product (cross join) of tables involved subjected to filters. Are you sure this is the correct query?
    The error you're getting may be because you've not yet populated DimProduct or may be because of logic you used in popultaing DimProduct causing it to miss some records which is what query is referring to in above case.
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • 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

  • Create one tables from 2 different tables

    Hi,
    How I can create one table from 2 different tables. Source tables have data and I want to include it in new table.
    I try this:
    create table NEW_ONE
    select * from OLD_ONE
    union
    select * from OLD_ONE2;
    But it didn't work correctly :/

    I don't have any error. This syntax create table NEW_ONE, but this table have columns only from OLD_ONE table :/ There aren't any column from OLD_ONE2 :/ Any suggestions?
    I don't forget about "as" in my query, only in this post.
    Edited by: tutus on Sep 8, 2008 6:36 AM

Maybe you are looking for