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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
_AlexandreRM_
Helper II
Helper II

DAX table filtering on "recursive" table

Hi, I have a specific problem I don't know how to solve. This is what I want to achieve.

 

My 1st table contains a list of materials with their components, without any information about the depth of the component:

MaterialComponent
AB
AC
AD
AE
AF
AG
HI
HJ
HK
HC
HL

 

My 2nd table contains the same data but formated differently, each row only contains an item, and the list of depth-1 level:

ItemSub-titem
AB
AC
AD
BE
BF
DG
HI
HJ
JK
JC
KL

 

To understand my sample data, keep in mind that I have here only 2 root materials, A and H.

 

In my report, I have a slicer to select an item from 'Material' column from the 1st table. Then I would like to have the 2nd table filtered to contain only relevant items and sub-items. For example, if I select A in the 1st table, I would like to have the 2nd looking like this:

ItemSub-titem
AB
AC
AD
BE
BF
DG

 

I need this for a custom visual, showing the bill of materials as a flow, from root level to deeper level.

 

I gave a look at CALCULATETABLE function, but I actually don't know how to parametrize it. I would be very, very grateful if someone has an idea on how to achieve this.

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@_AlexandreRM_ Maybe the code below. Basically a Complex Selector. The Complex Selector - Microsoft Power BI Community

Selector = 
  VAR __Components = DISTINCT('Table1'[Component])
  VAR __Item = MAX('Table2'[Item])
RETURN
  IF(__Item IN __Components,1,0)

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
_AlexandreRM_
Helper II
Helper II

@Greg_Decklerthank you for your explanation, I now see how I could achieve what I want. But I'm facing a new, probably more common problem.

 

Here is my links modelisation:

_AlexandreRM__0-1664047528477.png

 

And here is my report page:

_AlexandreRM__3-1664047807066.png

 

 

1 : 'BOM root materials' is used in the slicer (set to 10005129 in the screenshot).

2 : 'BOM expanded transposed' is showed in a table (equivalent to the Table1 Material/Component).

3 : I calculated the 1st row of your filter formula rows count.

4 : I displayed the Table2 Item/Sub-item with the result of the selector column.

 

The fact is, I don't see why my slicer filter isn't applied by powerbi in the 'Selector' custom column. I should have seen 8, and not 6324 (whatever I put in the slicer '1' this number doesn't change).

 

The left table shows the 'BOM expanded transposed' (Table1 Material/Component) content as expected, but the DISTINCT('BOM expanded transposed'[Composant]) calculation isn't filtered by the slicer.

 

There is probably something I don't understand about slicers interactions between tables and measures.

I finally spotted my error: I was using a calculated column instead of a measure, which don't handle the context the same way. So, problem solved! Thank you @Greg_Deckler !

Greg_Deckler
Community Champion
Community Champion

@_AlexandreRM_ Maybe the code below. Basically a Complex Selector. The Complex Selector - Microsoft Power BI Community

Selector = 
  VAR __Components = DISTINCT('Table1'[Component])
  VAR __Item = MAX('Table2'[Item])
RETURN
  IF(__Item IN __Components,1,0)

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors