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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
YO_CO
Frequent Visitor

Related data with cross filters

Hi all,

after 3 hours arguing with ChatGPT/Claude and getting 0 results, perhaps you can help with something I assumed was a simple matter but am struggling.

 

I have 2 tables:
FactOrders - containins primary order number and various details and values. Each primary order can appear more than once as it has different items:

FactOrders
OrderItemRegionValue
11AUS100
11BUS110
11CUS120
22AEMEA200
22BEMEA210
33AEMEA300
33BEMEA310
33CEMEA320
44AAPAC400
55AAPAC500
66AAPAC600

 

Links table - containing two columns: The primary order and linked orders.
Please note a primary order can also have 0 linked orders, in which case it will not show in this table, and it can also have multiple linked orders:

Links
Primary OrderLinked To
23
24
56

In this example we see order #2 is linked to 3 & 4, and #5 is linked to #6.
The links only work from Primary to linked, meaning 2 is linked to 3, but 3 is not considered linked to 2.

 

I wish to create a matrix visual which, when selecting an order on a slicer (can be any order from FactOrders table, linked or no), will show me the selected order and all related orders in a single column followed by different metrics.

 

For example, when selecting Order #1 I'll get the following visual as it has no related orders:

OrderItemValue
11A100
11B110
11C120

 

When selecting order #2 in a slicer I'd get the following results (order 2 + items + all related orders and their items):

OrderItemValue
22A200
22B210
33A310
33B320
33C330
44A400

 

when selecting #5, I'll see:

OrderItemValue
55A500
66A600

 

when selecting #6, I'll see only it as it's not considered related to anything:

OrderItemValue
66A600

 

How would I go about achieving this?

Thought it would be simple, but been struggling with it for the past few days.

Crossjoin won't help here as it's large tables in import mode.

 

Thank you!

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Create a disconnected table for use in the slicer like

Orders for slicer = DISTINCT( 'Fact Orders'[Order ID] )

Create a measure for use as a filter

Order is visible =
VAR CurrentOrder =
    SELECTEDVALUE ( 'Fact Orders'[Order ID] )
VAR ChosenOrder =
    SELECTEDVALUE ( 'Orders for slicer'[Order ID] )
VAR RelatedOrders =
    CALCULATETABLE ( VALUES ( Links[Linked To] ), Links[Order ID] = ChosenOrder )
VAR Result =
    IF ( CurrentOrder = ChosenOrder || CurrentOrder IN RelatedOrders, 1 )
RETURN
    Result

Add this measure as a filter to the matrix, to only show when the value is 1. Use the order ID from the fact table in the matrix.

View solution in original post

4 REPLIES 4
johnt75
Super User
Super User

Create a disconnected table for use in the slicer like

Orders for slicer = DISTINCT( 'Fact Orders'[Order ID] )

Create a measure for use as a filter

Order is visible =
VAR CurrentOrder =
    SELECTEDVALUE ( 'Fact Orders'[Order ID] )
VAR ChosenOrder =
    SELECTEDVALUE ( 'Orders for slicer'[Order ID] )
VAR RelatedOrders =
    CALCULATETABLE ( VALUES ( Links[Linked To] ), Links[Order ID] = ChosenOrder )
VAR Result =
    IF ( CurrentOrder = ChosenOrder || CurrentOrder IN RelatedOrders, 1 )
RETURN
    Result

Add this measure as a filter to the matrix, to only show when the value is 1. Use the order ID from the fact table in the matrix.

YO_CO
Frequent Visitor

Thanks @johnt75 , that... actually works!

Appreciate it!

Much simpler and more effective than anything AI gave me.

 

How would you alter this so that if more than one order is selected it will still display only the relevant data?

Currently if more than one is selected it shows nothing.

You can adapt it to cope with mulitple selected orders like

Order is visible =
VAR CurrentOrders =
    SELECTEDVALUE ( 'Fact Orders'[Order ID] )
VAR ChosenOrders =
    VALUES ( 'Orders for slicer'[Order ID] )
VAR RelatedOrders =
    CALCULATETABLE (
        VALUES ( Links[Linked To] ),
        TREATAS ( ChosenOrders, Links[Order ID] )
    )
VAR Result =
    IF ( CurrentOrder IN ChosenOrders || CurrentOrder IN RelatedOrders, 1 )
RETURN
    Result
YO_CO
Frequent Visitor

Wonderful, thank you very much!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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