Forum Discussion

Tcerginer's avatar
Tcerginer
Regular Visitor
9 years ago
Solved

MATCH between 2 tables

Hello Community,

 

I am trying to crease a measure using something similar to the MATCH function from excel.

 

I have a table(1) that tells me which of the company's training modules my coworkers have completed. Another relationship between tables(2) tells me which modules each coworker must take. I would like to use something like MATCH that would scan table 2 and tells me if there is a match in table 1, if true it would return me as "Completed" and if false "Due".

 

Below there is an image to help understanding

 

 http://imgur.com/a/W27mi

 

I tried using CONTAINS, but did not succeed.

 

Appreciate your help!

 

 

 

 

 

 

  • BhaveshPatel's avatar
    BhaveshPatel
    9 years ago

    Another solution using Query Editor.

     

    1. Left Outer Join

    2. Conditional Column.

     

    See the attached screenshots.

    LEFT OUTER JOINEXPAND COLUMNCONDITIONAL COLUMNFINAL OUTPUT

7 Replies

  • You can use "LEFT OUTER JOIN" in Merge Queries in Query Editor to get the desired results. 

     

    It includes all the rows in the Courses table in the results, whether or not there is a match on the CourseID column in the Coursecompletionstatus table.  Where there is no matching CourseID for a Course, the row contains a null value.

  • v-caliao-msft's avatar
    v-caliao-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi Tcerginer,

     

    Tested it on my local environment using the sample data below.

    We can get the the expected result by using the DAX below.

    Column = IF(ISBLANK(LOOKUPVALUE(Table1[Coworkers],Table1[Modules ],Table2[ModulesMustTake],Table1[Coworkers],Table2[Coworkers])),"Due","Completed")

     

    Regards,

    Charlie Liao

     

    • BhaveshPatel's avatar
      BhaveshPatel
      Icon for Super User rankSuper User

      Another solution using Query Editor.

       

      1. Left Outer Join

      2. Conditional Column.

       

      See the attached screenshots.

      LEFT OUTER JOINEXPAND COLUMNCONDITIONAL COLUMNFINAL OUTPUT

    • Tcerginer's avatar
      Tcerginer
      Regular Visitor

      Thank you very much v-caliao-msft Greg_Deckler and BhaveshPatel for helping me! I'm new with PowerBI and I am self teaching Relational Database from scratch, you are really helping me out! Your solutions aren´t working yet, because the problem is a bit more elaborated and I should have been more specific.

       

      As the company I am working have many employees, the modules that must be taken depends on the employee's function and those modules are susceptible of change over time, I created the relational model below:

       

      Obs: 'trail' means all the modules that a function should take. The doctor's trail is different from engineer's trail..

       

       

       

      As you can see, I dont have this 'table2' to use the LOOKUPVALUE. But we know that the tables 'coworkers' and 'trail' are related through table 'function'. Is it possible to generate this 'table2' using Dax or queries so we could use lookupvalue?

       

      Another point:

       

      It is possible for a coworker to take modules that aren´t on their trails! A Teacher could take Math if wanted. Those would be displayed in another separated table, as they aren´t obligatory.

       

      I hope could make myself clear. English is not my mother language.

       

      Thanks again for the support!

       

      Tom

       

      • Stachu's avatar
        Stachu
        Icon for Community Champion rankCommunity Champion

        BhaveshPatel solution will work, you just need to do it 2 times

        1) merging Coworkers with Trail

        2) merging 1) with Graduated