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

Display IDs that match all selections in one slicer

Hi
I have two tables that are connected:

1. warehouse dimension
2. inventory fact

I want to select various inventory elements in a slicer and only show the name of the warehouses that have all selected elements. 

Later I need to add an extra slicer that can be used as an OR input. SO that I can return the selections of multiple elements from one slicer OR the selection of multiple elements from another slicer. Both with the same values of inventory elements. 

gedal_0-1625739815035.png


I've tried to make use of this solution (can't make it work 😞) :
https://community.powerbi.com/t5/Desktop/Result-of-multiple-select-in-slicer-should-match-all-select...
and other solutions such as making a new table with distinct inventory elements and use it as slicer etc. List is getting long!

Does anyone have an idea of how to produce this or guide me in the right direction?

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi  @gedal ,

 

Create 2 measures as below:

Judge = 
var _count=CALCULATE(COUNT('Inventory fact table'[warehouse id]),FILTER(ALL('Inventory fact table'),'Inventory fact table'[element] in FILTERS('slicer table'[element])&&'Inventory fact table'[warehouse id]=MAX('Inventory fact table'[warehouse id])))
Return
IF(_count<COUNTX(ALLSELECTED('slicer table'[element]),'slicer table'[element]),BLANK(),_count)
Return = 
var _warehouseid=CALCULATETABLE(VALUES('Inventory fact table'[warehouse id]),FILTER(ALL('Inventory fact table'),'Inventory fact table'[element] in FILTERS('slicer table'[element])&&'Inventory fact table'[Judge]<>BLANK()))
var _name=CALCULATETABLE(VALUES('warehouse dimension table'[warehouse name ]),FILTER(ALL('warehouse dimension table'),'warehouse dimension table'[warehouse id ] in _warehouseid))
Return
CONCATENATEX(_name,'warehouse dimension table'[warehouse name ],",")

And you will see:

vkellymsft_3-1626060742193.png

 

vkellymsft_2-1626060728427.png

vkellymsft_4-1626060752239.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

 

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi  @gedal ,

 

Create 2 measures as below:

Judge = 
var _count=CALCULATE(COUNT('Inventory fact table'[warehouse id]),FILTER(ALL('Inventory fact table'),'Inventory fact table'[element] in FILTERS('slicer table'[element])&&'Inventory fact table'[warehouse id]=MAX('Inventory fact table'[warehouse id])))
Return
IF(_count<COUNTX(ALLSELECTED('slicer table'[element]),'slicer table'[element]),BLANK(),_count)
Return = 
var _warehouseid=CALCULATETABLE(VALUES('Inventory fact table'[warehouse id]),FILTER(ALL('Inventory fact table'),'Inventory fact table'[element] in FILTERS('slicer table'[element])&&'Inventory fact table'[Judge]<>BLANK()))
var _name=CALCULATETABLE(VALUES('warehouse dimension table'[warehouse name ]),FILTER(ALL('warehouse dimension table'),'warehouse dimension table'[warehouse id ] in _warehouseid))
Return
CONCATENATEX(_name,'warehouse dimension table'[warehouse name ],",")

And you will see:

vkellymsft_3-1626060742193.png

 

vkellymsft_2-1626060728427.png

vkellymsft_4-1626060752239.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

 

Thank you so much! this was really great!

I needed the warehouses on individual row, so that I can add extra information to each displayed warehouse. So I changed the code a little and made it into a flag instead.

The return measure is now:

ifcointainswarehouse =

Var selection = SELECTEDVALUE(consultants[Konsulent])

var _warehouseid1=
CALCULATETABLE(
VALUES('Inventory fact table'[warehouse id]),
FILTER(ALL('Inventory fact table'),
'Inventory fact table'[element] in FILTERS('elementFilter1'[Element]) && 'Inventory fact table'[Judge1]<>BLANK()
)
)

var _name1=
CALCULATETABLE(
VALUES('warehouse dimension table'[warehouse name ]),
FILTER(
ALL('warehouse dimension table'),
'warehouse dimension table'[warehouse id] in _warehouseid1))

var _warehouseid2=
CALCULATETABLE(
VALUES('Inventory fact table'[warehouse id]),
FILTER(ALL('Inventory fact table'),
'Inventory fact table'[element] in FILTERS('elementFilter2'[Element]) && 'Inventory fact table'[Judge2]<>BLANK()
)
)

var _name2=
CALCULATETABLE(
VALUES('warehouse dimension table'[warehouse name ]),
FILTER(
ALL('warehouse dimension table'),
'warehouse dimension table'[warehouse id ] in _warehouseid2))

VAR check =
IF(
CONTAINS(_name1, 'warehouse dimension table'[warehouse name ], selection),
1,
IF(
CONTAINS(_name2, 'warehouse dimension table'[warehouse name ], selection),
1,
0
)
)

RETURN check

Then I make a table with all warehouses from the dimension table and filter it with the return measure 🙂

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.