Forum Discussion

teado25's avatar
teado25
Frequent Visitor
6 years ago
Solved

Using a single slicer on an unrelated column

I've created a table within Power BI that includes 2 columns, 'Allocated Worker' (column A) and 'Previous Allocated Worker' (column B). I want users to be able to choose their name from a single slic...
  • Anonymous's avatar
    Anonymous
    6 years ago

    In powerBI, you cannot have two active relationships between two tables. If you have a relationship active between the Workers table and the WorkerA column, the data will be filtered by that relationship by default. PowerBI will use that column to "assign" the values from the fact table to the dimension column when putting data in a visual or matrix table or when filtering with a slicer

    Of course, you could also have another way of sorting the data. Like in your situation, where there is also a WorkerB column. If you need to distribute data based on this other relationship, you need some way to activate the relationship, as if it was the default one. You can do that using USERELATIONSHIP. USERELATIONSHIP is a parameter of the CALCULATE function that allows you to do that. 

    The two measures could be:

    DatabyWorkersA:
    COUNTROWS(
                         [Table]
    )

    When filtering, this measure will be filtered by the default relationship (assigning values based on the WorkersA column)


    DatabyWorkersB:
    CALCULATE(
            COUNTROWS(
                         [Table] 
                      ),
             USERELATIONSHIP(
             WorkersTable[Worker],
             Table[WorkerB]
              )
    )

    When filtering, this measure will be filtered by the activated relationship (assigning values based on the WorkersB column)

    I hope this is somewhat clear