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! Request now

Reply
Anonymous
Not applicable

How do I create the relationships

Hi,

 

I am new to PowerBi and currently stuck on the relationship between the tables below.

 

Orders

chealsea_0-1649027925532.png

 

Stock Allocation

chealsea_1-1649028033380.png

 

Power Bi Desktop

chealsea_2-1649028160820.png

 

How to create the relationship to allow the slicer filter on both tables by branch?

 

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous 

You can try this,

(1) Create the auxiliary tables

Table = DISTINCT( SELECTCOLUMNS(Orders,"Sales Date",Orders[Sales Date],"Order",Orders[Order]))

vxiaotang_0-1651112201410.png

vxiaotang_2-1651112292155.png

(2) create the measures below,

Qty = 
CALCULATE (
    SUM ( Orders[Qty] ),
    FILTER (
        ALL ( Orders ),
        Orders[Branch] = SELECTEDVALUE ( 'Branch Filter'[Branch] )
            && Orders[Sales Date] = MIN ( 'Table'[Sales Date] )
            && Orders[Order] = MIN ( 'Table'[Order] )
    )
)
Allocation = 
CALCULATE (
    SUM ( 'Stock Allocation'[Qty] ),
    FILTER (
        ALL ( 'Stock Allocation' ),
        'Stock Allocation'[Branch] = SELECTEDVALUE ( 'Branch Filter'[Branch] )
            && 'Stock Allocation'[Sales Date] = MIN ( 'Table'[Sales Date] )
            && 'Stock Allocation'[Order] = MIN ( 'Table'[Order] )
    )
)

result

vxiaotang_4-1651112469492.png

Best Regards,

Community Support Team _Tang

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

View solution in original post

3 REPLIES 3
mahoneypat
Microsoft Employee
Microsoft Employee

Create another table with just the Branch values, either in the query editor by referencing one of your existing tables, or with a DAX table with DISTINCT(Orders[Branch]) for example. You can then relate the new table to both columns on the Branch columns.

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Hi Pat,

 

Thanks for your reply. I have tried this method before, but I couldn't get the correct number on allocation Qty.

 

chealsea_0-1649036877862.png

chealsea_1-1649037313864.png

 

 

Hi @Anonymous 

You can try this,

(1) Create the auxiliary tables

Table = DISTINCT( SELECTCOLUMNS(Orders,"Sales Date",Orders[Sales Date],"Order",Orders[Order]))

vxiaotang_0-1651112201410.png

vxiaotang_2-1651112292155.png

(2) create the measures below,

Qty = 
CALCULATE (
    SUM ( Orders[Qty] ),
    FILTER (
        ALL ( Orders ),
        Orders[Branch] = SELECTEDVALUE ( 'Branch Filter'[Branch] )
            && Orders[Sales Date] = MIN ( 'Table'[Sales Date] )
            && Orders[Order] = MIN ( 'Table'[Order] )
    )
)
Allocation = 
CALCULATE (
    SUM ( 'Stock Allocation'[Qty] ),
    FILTER (
        ALL ( 'Stock Allocation' ),
        'Stock Allocation'[Branch] = SELECTEDVALUE ( 'Branch Filter'[Branch] )
            && 'Stock Allocation'[Sales Date] = MIN ( 'Table'[Sales Date] )
            && 'Stock Allocation'[Order] = MIN ( 'Table'[Order] )
    )
)

result

vxiaotang_4-1651112469492.png

Best Regards,

Community Support Team _Tang

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

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