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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
NetromEner
Frequent Visitor

Lookup cost price based on 4 column values matching in another row

Hi,

I need some help on how to write a measure to find a price for a line item in a table containing all transactions, including both Sales orders and purchase orders.

The link between the Sale Order Price and purchase Order price is 4 values listed on the sale order line and what I want to find is the Purchase Order price to calculate profit.

The link between Sales order price and Purchase order price is Supplier PO+Item+Product Number+QTY.

 

TransactionProduct NumberItemSupplier POQTYPriceType
5390698153907545100Sales Order
5390758104580Purchase Order

 

So in the above example I would need to find Price 80 as this match the link Supplier PO+Item+Product Number+QTY

Appreciate some help with this.

1 ACCEPTED SOLUTION

@NetromEner 

Please try

Cost Price =
MAXX (
FILTER (
CALCULATETABLE (
'Table',
ALLEXCEPT ( 'Table', 'Table'[Item], 'Table'[Product Number], 'Table'[QTY] )
),
'Table'[Transaction] = EARLIER ( 'Table'[Supplier PO] )
&& 'Table'[Type] = "Purchase Order"
),
'Table'[Price]
)

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

@NetromEner 
Supplier PO is not matching. However, assuming this is just a typo mistake, please try

Cost Price =
MAXX (
    FILTER (
        CALCULATETABLE (
            'Table',
            ALLEXCEPT (
                'Table',
                'Table'[Supplier PO],
                'Table'[Item],
                'Table'[Product Number],
                'Table'[QTY]
            )
        ),
        'Table'[Type] = "Purchase Order"
    ),
    'Table'[Price]
)

Hi tamerj1 and thanks for your feedback. You see the problem is that First line refers to Supplier PO 539075, which again is listed as a separate line with 539075 as transaction ID. So I want to find with price where Supplier PO+Item+Product Number+QTY = Transaction+Item+Product Number+QTY

 

Hope this explains the problem I am facing, I have to swicth Coloumn when looking up the price for connected Purchase Order

@NetromEner 

Please try

Cost Price =
MAXX (
FILTER (
CALCULATETABLE (
'Table',
ALLEXCEPT ( 'Table', 'Table'[Item], 'Table'[Product Number], 'Table'[QTY] )
),
'Table'[Transaction] = EARLIER ( 'Table'[Supplier PO] )
&& 'Table'[Type] = "Purchase Order"
),
'Table'[Price]
)

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.