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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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