Forum Discussion

baronraghu's avatar
baronraghu
Helper III
8 years ago

Join two filtered tables

Hi All,

 

I have two tables 

 

Table 1

BuyerCityQuantity Bought
AdamLA17
BoBLondon80
CharleMoscow37
DiazLA28
EllenLA82
AlokDelhi52
AnkitLondon51
AdamDelhi73
BoBDelhi86
CharleLondon20
DiazLA30
EllenLA50
AlokDelhi78
AnkitDelhi85

 

Table 2 

 

CityTypeHousesShopsGDP
LAA317896
LAB2981653
LAC1831685
LAD4131016
LondonA26017310
LondonB2331017
LondonC2271891
LondonD1521094
DelhiA470774
DelhiB4371514
DelhiC378682
DelhiD1641303

 

I need to merge certain rows of table 1 with that of table 2 based on slicer selection, like below

 

I have a hierchey Slicer with following levels Buyers> City > Type

 

So if my selections are (Adam, LA, B) on all the three slicers, I want to create a table to be made with folowing headers

 

Buyer | City | Type | HOuses| Shops | GDP

 

I tried Union function like this 

 

New table= union(if(isfiltered(all(table1[buyers]),table1[buyers],blank()),if(isfiltered(table2[type]),Filter(table2,Allexcept(table2,table2[type]))

 

The formula doesnt seem to work properly. 

 

Please help

 

Thanks

Raghu

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi baronraghu

     

    You need to join both the tables either in DAX or in Power Query.

     

    In Power Query :

    Do Merge both tables and retain required columns only. Once slicers filters are applied, your table will be automattically applied here as well. Pls make sure proper relationship is defined.

     

    In DAX:

    In Modelling -> New Table-> You may have to use NATURALINNERJOIN

     

    Hope this gives you the direction.

     

    Thanks

    Raj

    • baronraghu's avatar
      baronraghu
      Helper III

       Thanks Anonymous

       

      I tried using the naturalinnerjoin function, but it didnt work :(

      • Anonymous's avatar
        Anonymous
        Not applicable

        You can try in Power Query as well, as i mentioned above.

         

        Thanks
        Raj