Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Filter/no Filter for specific entry between two tables

I have 2 tables, in the first table (T_FACT_RevCost) are departments and financial figures, in the second one are the departments (T_DIM_Department). The tables are 1-* linked together. Selecting a department in T_DIM_Department should filter the T_FACT_RevCost - except for the "special" departments HR and Controlling, they should see everything in the FACT table. If I select HR or Controlling in the visual, the filter should be removed. And no, choosing nothing in the visual is not an option

 

T_Department

DepartmentNoFilter
Controlling1
HR1
Dep10
Dep20
Dep30
Dep40

 

T_FACT_RevCost

DepartmentRevCostPeriod
Controlling1052021-07-01
HR20152021-07-01
Dep130252021-07-01
Dep240352021-07-01
Dep350452021-07-01
Dep460552021-07-01
Controlling1052021-08-01
HR21162021-08-01
Dep131172021-08-01
Dep241222021-08-01
Dep351322021-08-01
Dep452422021-08-01

 

 

Should display all departments / values

 

 

File: 

Filter_Test.pbix – OneDrive (live.com)

 

Help is really appreciated

Toddy

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Just create a separate table with departments that you'll put in the slicer as above (it'll be a disconnected table) and keep in there the (hidden) field DepartmentSlicer[NoFilter]. Once you have this, create a measure that will return 1 if  1) the currently visible department (this time you'll drag the department from the T_Department onto the visual) - you can use ISINSCOPE to check for the currently visible department - is the one selected in the slicer and at the same time NoFilter for it is 0, or 2) if NoFilter is 1 for the currently selected value in the slicer. This logical condition codes the behaviour you want for your rows. Then use the measure to filter the rows in your visual using the Filter Pane.

     

    Of course, there are other ways to do it. You could create a table that would store the mappings between FromDepartmentID and ToDepartmentID. It would be a factless fact table. The FromDepartmentName would be exposed, so that it could be put on the slicer. Depending on your model and requirements, you could/should delete the T_Department table. The mapping table would be connected to your fact either directly (many-to-many) or via a (hidden) T_Department table. This all depends on the requirements. Then, you'd slice by FromDepartment and it would work the way you want thanks to the mapping table.

     

    It would be much easier to demonstrate... but I don't have time (yet).

     

    However, you should never forget that your models should never allow RI violations. If you neglect to ensure it, you'll be in trouble sooner or later.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for your reply. I will try idea no 1.

      I'll come back on this after my vacation