Forum Discussion

Rajani1085's avatar
Rajani1085
Frequent Visitor
1 year ago
Solved

Left outer join creating many to many relation - DB2 database

Hello Experts, I am stuck with a data model issue in Power BI. I have 2 tables (employee and employee emergency contact) joined in left outer join relation with one - many. I created the left outer ...
  • Rajani1085's avatar
    Rajani1085
    1 year ago

    Thank you v-kpoloju-msft for your response. I was able to solve the issue by creating a new table using DAX for emergency contact. I Unioned Employee and Emergency contact based on SSN and for the missing SSN from emergency contact, I am showing blank for all the other columns. This resolved the left outer join issue and I didnt need to merge the tables. For the other table joins, I used a regular Employee table one to many join. Here is the DAX. 

    EMERGENCY_CONTACT =
    UNION (
        SELECTCOLUMNS (
            'EMERGENCY CONTACT',
            "SSN", 'EMERGENCY CONTACT'[Ssn],
            "Contact Name First",'EMERGENCY CONTACT'[Contact Name First],
            "Contact Name Last",'EMERGENCY CONTACT'[Contact Name Last],
            "Contact Name Middle",'EMERGENCY CONTACT'[Contact Name Middle],
            "Contact Email",'EMERGENCY CONTACT'[Contact Email],
            "Contact Phone Cell",'EMERGENCY CONTACT'[Contact Phone Cell],
            "Contact Phone Home",'EMERGENCY CONTACT'[Contact Phone Home],
            "Contact Phone Work",'EMERGENCY CONTACT'[Contact Phone Work],
            "Contact Phone Work Ext",'EMERGENCY CONTACT'[Contact Phone Work Ext],
            "Contact Relationship",'EMERGENCY CONTACT'[Contact Relationship],
            "Emergency Contact Sequence",'EMERGENCY CONTACT'[Emergency Contact Sequence],
            "Primary Flag",'EMERGENCY CONTACT'[Primary Flag]
        ),
        SELECTCOLUMNS (
            EXCEPT (
                SELECTCOLUMNS('EMPLOYEE DETAIL', "SSN",'EMPLOYEE DETAIL'[Social Security Number]),
                SELECTCOLUMNS('EMERGENCY CONTACT', "SSN",'EMERGENCY CONTACT'[Ssn])),
           
            "SSN", [SSN],
            "Contact Name First", BLANK(),
            "Contact Name Last", BLANK(),
            "Contact Name Middle",BLANK(),
            "Contact Email", BLANK(),
            "Contact Phone Cell", BLANK(),
            "Contact Phone Home", BLANK(),
            "Contact Phone Work",BLANK(),
            "Contact Phone Work Ext",BLANK(),
            "Contact Relationship",BLANK(),
            "Emergency Contact Sequence",BLANK(),
            "Primary Flag",BLANK()

        )
    )