Handling multiple fact tables in Qlikview

后端 未结 4 810
慢半拍i
慢半拍i 2021-01-12 10:18

I have a PostgreSQL database containing various education data such school-level test scores and enrollment figures. I need to separate enrollment from test scores because

4条回答
  •  囚心锁ツ
    2021-01-12 10:27

    The two quickest ways I can think of:

    A) You can just left join the fact table into the corresponding tables that they are used in. You will just need to rename the fields to avoid conflicts with the other tables.

    B)You can rename the common fields, which can be done by

    1. using a QUALIFY (before you load the fact tables) and UNQUALIFY (after you load the fact tables)
    2. renaming the field using "[Old Field Name] as [New Field Name]"

    Assuming that the fact tables have unique id field names that can be linked to the main tables , you shouldn't have to rename anything in the main tables

    I'd go with B-1, since that seems a little less of a hassle.

    QUALIFY
    A,
    B,
    C,
    ID;
    
    FactTable1:
    Load ID,
    A,
    B,
    C,
    From [FactTable1];
    
    FactTable2:
    Load ID,
    A,
    B,
    C,
    From [FactTable2];
    
    UNQUALIFY
    A,
    B,
    C,
    ID;
    

    EDIT: If you want to create a link table from these, you can concatenate the fact tables into one table where you put all the columns into it (there will be nulls for a lot of the columns, but QlikView is good with nulls).

    What i usually do is load the fact tables in and create an id field (either RowNo() or autonumberhash128([list of unique id fieldnames]), then when i load them into a link table, I include that id field in the link table as well. Finally, i drop the all the common fields from the fact tables, so they only exist in the link table.

提交回复
热议问题