Forum Discussion

Mardo's avatar
Mardo
Frequent Visitor
8 years ago
Solved

Table Relations - counting the missing rows

Hello,

 

I have created two different tables from the main CUBE. The first table contains 1544 rows and shows the employee in 2017. The second table has 1804 rows that shows the number of employees in 2018. (The number of employees is increasing!).

 

Now, my question is: HOW to determine the number of employees who left OR joined the company??? We have Employee-ID as a key in both tables. Please anyone could help?

 

Thanks in advance,

Regards,

Mardo

6 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    SELECT * FROM 2018 cy

    RIGHT JOIN 2017 ly

    ON cy.id = ly.id

    WHERE cy.id IS NULL

     

     

     

    • Mardo's avatar
      Mardo
      Frequent Visitor

      Hello Richard,

       

      Thank you for your reply.

       

      I am just wondering if that code was a DAX-code?? I would need a DAX-formula to compare the values (User-ID) in the two columns from the two tables (to determine what is missing?)

       

      I hope you understand my point?

       

      Kindest regards,

      Mardo

      • v-yuta-msft's avatar
        v-yuta-msft
        Community Support

        Hi Mardo,

         

        So your requirement is equal to achieve rows only appear in table1 and rows only appear in table2, right?

         

        Merge(Left Anti and Right Anti) can meet your requirement, click query editor->Merge Queries->Select join kind as left anti or right anti.

         

        After merged, you get two tables that contains only people left the company and only people joined the company.

         

        Finally, apply and create a measure using count(table) to calculate the number of people.

         

        Regards,

        Jimmy Tao