Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
andyhowes64
Frequent Visitor

Filtering a data set based on the result of a filtered table

Hi.

 

I'm very new to Power BI and could do with some help regarding filtering data.

 

I have a query pulling in a sales list of around 500,000 rows of data.  This data contains around 3,000 distinct products and 2,000 customers.

 

What I would like to do is create a slicer where a user can select a particular product from the list, this identifies all customers who have bought that product and then returns a list of all products bought by these customers.

 

As an example, from the below table the user would select product A, which has only been purchased by Customers 1 & 2:

ProductCustomerRevenue
A1             99
A1             36
A2             80
A2             15
A1             23
A2             64
B2             45
B1             99
B4             88
B3             62
B2               5
B1               8
C3             47
C3             70
C4             67
C4             35
C3             74
C3             68

 

The output table would then filter the above table for customer 1 & 2 returning all the products that they have purchased:

ProductCustomerRevenue
A1             99
A1             36
A2             80
A2             15
A1             23
A2             64
B2             45
B1             99
B2               5
B1               8

 

The filtering would need to be based off of a user friendly filtering method, which from my limited experience appears to be slicers.

 

Apologies if this is very basic and I have missed something simple.  I have spent a few hours looking for a possible solution but have ended up down quite a few dead ends. Whilst I am new to Power BI, I have some experience of Power Query and can merge and filter queries as required.

 

Thanks in advance for any help.

Andy 

1 ACCEPTED SOLUTION
v-cherch-msft
Employee
Employee

Hi @andyhowes64 

You may create a slicer table then use it as slicer.Make sure there's no relationship.Then new a measure to filter the table.

New Table:

 

Slicer = DISTINCT(Data[Product])

 

 

Measure =
VAR cus =
    CALCULATETABLE (
        VALUES ( Data[Customer] ),
        FILTER ( ALL ( Data ), Data[Product] IN VALUES ( Slicer[Product] ) )
    )
RETURN
    IF ( MAX ( Data[Customer] ) IN cus, 1 )

1.png

 

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-cherch-msft
Employee
Employee

Hi @andyhowes64 

You may create a slicer table then use it as slicer.Make sure there's no relationship.Then new a measure to filter the table.

New Table:

 

Slicer = DISTINCT(Data[Product])

 

 

Measure =
VAR cus =
    CALCULATETABLE (
        VALUES ( Data[Customer] ),
        FILTER ( ALL ( Data ), Data[Product] IN VALUES ( Slicer[Product] ) )
    )
RETURN
    IF ( MAX ( Data[Customer] ) IN cus, 1 )

1.png

 

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks @v-cherch-msft  this is awesome.  You've saved me a lot of potential workarounds to do this.

 

Thanks again.

Andy

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.