Forum Discussion

alfsender's avatar
alfsender
New Member
5 years ago
Solved

Power BI Slicer using multiple table joins not working

I am new to PowerBI and trying to create a report along with a slicer. When I import my tables in Power BI, I see it recognizes relation properly. But when I add slicer it does not work.

My Tables are as below...


Table:1 > Region

idName
1APAC
2EMEA

 

Table:2 > Territory

idname
1Japan
2India
3Sri Lanka
4Japan
5London
6Paris
7Italy


Table:3 > Company

idname
1company-1 (Note: part of Apac region with India & Sri Lanka territory)
2company-2 (Note: part of Emea region with Paris & Italy territory)


Table:4 > region_territory


idregion_idterritory_id
111
212
313
414
525
626
727


Table:5 > company_region_territory

idcompany_idregion_territory_id
112
213
326
427


I am trying to create a slicer by "Region" name, so when I select Region as "APAC" it should show me total count of "Company" which has Region APAC assigned. When I connect PowerBI to my DB and select all above tables I see power bi has identified relationship properly, but still slicer does not work as expected.

Please share your valuable feedback to resolve this issue.


Thank you.

  • Hi  alfsender ,

     

    Create a measure as below:

    Measure = 
    var _id=CALCULATE(MAX('Region'[id]),FILTER(ALL(Region),'Region'[Name]=SELECTEDVALUE(Region[Name])))
    var _territory=CALCULATETABLE(VALUES('region_territory'[territory_id]),FILTER(ALL(region_territory),'region_territory'[region_id]=_id))
    var _companyid=CALCULATETABLE(VALUES('company_region_territory'[company_id]),FILTER(ALL(company_region_territory),'company_region_territory'[region_territory_id] in _territory))
    Return
    COUNTX(_companyid,[company_id])

    And you will see:

    For the related .pbix file,pls see attached.

     

    Best Regards,
    Kelly

    Did I answer your question? Mark my post as a solution!

1 Reply

  • v-kelly-msft's avatar
    v-kelly-msft
    Icon for Community Support rankCommunity Support

    Hi  alfsender ,

     

    Create a measure as below:

    Measure = 
    var _id=CALCULATE(MAX('Region'[id]),FILTER(ALL(Region),'Region'[Name]=SELECTEDVALUE(Region[Name])))
    var _territory=CALCULATETABLE(VALUES('region_territory'[territory_id]),FILTER(ALL(region_territory),'region_territory'[region_id]=_id))
    var _companyid=CALCULATETABLE(VALUES('company_region_territory'[company_id]),FILTER(ALL(company_region_territory),'company_region_territory'[region_territory_id] in _territory))
    Return
    COUNTX(_companyid,[company_id])

    And you will see:

    For the related .pbix file,pls see attached.

     

    Best Regards,
    Kelly

    Did I answer your question? Mark my post as a solution!