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
nschmidt
Frequent Visitor

How do I use a slicer filter and hasonevalue to filter another column

So this is pretty complicated so I hope I explain this correctly. I have two tables that are connected in a one to many relationship. (example data below). Because I'm in an SASS model I can't use selectedvalue but my goal is the following:

 

I have a slicer in the visualization for Transaction vendor and when I select "Jones" I want to be able to count the number of part numbers by Jones in the product table. I thought maybe this would work but I'm stuck:

 

CALCULATE(COUNTROWS('PRODUCT'),if(HASONEVALUE(SALES[Transaction Vendor Name]),filter('PRODUCT','PRODUCT'[Primary Vendor Name]=values(SALES[Transaction Vendor Name])),ALL('PRODUCT')))

 

Product -> Sales (part number is the key)

 

Part NumberPrimary Vendor Name Part NumberTransaction Vendor NameSales
ABJones ABJones $    10.00
ACJones ABJones $    15.00
ADRidge ABJones $    41.00
AERidge AFRidge $  100.00
AFRidge AFRidge $    45.00
   AFRidge $  145.00
   AFRidge $    45.00
1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, @nschmidt 

According to your description and sample data, I think that the problem exists in the relationship between your two tables because you said that the key between them is [Part Number], but you want to slice the value based on the selection of [Primary Vendor Name], which causes the filter problems, I suggest you to create a new table for the Slicer, you can try my steps:

  1. Create a calculated table for Slicer:

Slicer =

SUMMARIZE('Sales',[Transaction Vendor Name] )

v-robertq-msft_0-1614330278109.png

And don’t connect it with other tables:

v-robertq-msft_1-1614330278122.png

 

  1. Create a measure like this:
Count =

CALCULATE(

    COUNT('Product'[Part Number]),

    FILTER(

        ALL('Product'),

        [Primary Vendor Name]=VALUES(Slicer[Transaction Vendor Name])))
  1. Then create a Slicer and place ‘Slicer’[Transaction Vendor Name], and a card chart to place the measure, like this:

v-robertq-msft_2-1614330278131.png

 

And you can get what you want.

You can download my test pbix file here

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

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

3 REPLIES 3
v-robertq-msft
Community Support
Community Support

Hi, @nschmidt 

According to your description and sample data, I think that the problem exists in the relationship between your two tables because you said that the key between them is [Part Number], but you want to slice the value based on the selection of [Primary Vendor Name], which causes the filter problems, I suggest you to create a new table for the Slicer, you can try my steps:

  1. Create a calculated table for Slicer:

Slicer =

SUMMARIZE('Sales',[Transaction Vendor Name] )

v-robertq-msft_0-1614330278109.png

And don’t connect it with other tables:

v-robertq-msft_1-1614330278122.png

 

  1. Create a measure like this:
Count =

CALCULATE(

    COUNT('Product'[Part Number]),

    FILTER(

        ALL('Product'),

        [Primary Vendor Name]=VALUES(Slicer[Transaction Vendor Name])))
  1. Then create a Slicer and place ‘Slicer’[Transaction Vendor Name], and a card chart to place the measure, like this:

v-robertq-msft_2-1614330278131.png

 

And you can get what you want.

You can download my test pbix file here

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@nschmidt , I not sure on need of all product , so add that if needed

 

try like

CALCULATE(COUNTROWS('PRODUCT'),filter('PRODUCT','PRODUCT'[Primary Vendor Name] in values(SALES[Transaction Vendor Name]) && HASONEVALUE(SALES[Transaction Vendor Name])))

I'm getting the following error message:

 

nschmidt_0-1614101275923.png

 

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.