Forum Discussion

Rate's avatar
Rate
Helper III
7 years ago
Solved

Help with slicer for multiple Columns in Same Table (To and From)

Hello!   I am struggling with a Report I am building for controlling the stock of some of our users.  We can have multiple types of stock movements, and the users can receive and give stock in b...
  • Ashish_Mathur's avatar
    7 years ago

    Hi,

    You may download my PBI file from here.

    Hope this helps.

  • Anonymous's avatar
    Anonymous
    7 years ago

    Rate  - There are pros/cons to each of the 2 solutions:

    1. My solution does not duplicate rows in the fact table, but it creates a non-intuitive (and likely slow) filter.

    2. Ashish_Mathur 's solution contains duplicate rows, but creates a natural relationship/filter. Duplicate rows means that the fact table will only produce the correct results if you apply a filter.

     

    There is a 3rd solution as well, which would create a larger User table instead of duplicating rows in the fact table and also create a natural relationship/filter:

    1. Create the modified User Slicer Calculated Table:

     

    User Slicer 2 = 
    UNION(
        DISTINCT(SELECTCOLUMNS(Table2,"User",[User_From], "User Combo", [User_From] & "->" & [User_to])), 
        DISTINCT(SELECTCOLUMNS(Table2,"User",[User_to], "User Combo", [User_From] & "->" & [User_to]))
    )

    2. Create a new Calculated Column on your fact table:

     

     

    User Combo = [User_From] & "->" & [User_to]

    3. Create a Relationship between your fact table and User Slicer table, on the User Combo column. It will need to be a Many-to-Many relationship, with User Slicer filtering the fact table.

     

    4. Create a Measure:

     

    Quantity Measure 2 = SUM(Table2[Quantity])

     

     

    All 3 of these solutions produce the results you are looking for - you will need to consider / test the trade-offs between them. The disadvantage of the 3rd solution is that it uses a larger dimension table, with a more granular user key in the fact table. This means the index of the User Combo will have more distinct values and therefore be less efficient than Ashish_Mathur 's Value column.

    Cheers!

    Nathan