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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Max bid for each sell

Hey Community!

So I have the following problem:

I have 2 tables, one containing different bids for a product, and one containing the price, date etc. to which the product was sold.

The tables look like this:

Table bids:

Bid_id 

Start_time

End_time

Product_type

price

1

18.01.2020 06:00:00

18.01.2020 06:02:33

blue

5 €

2

18.01.2020 06:00:07

18.01.2020 06:00:43

blue

7 €

3

18.01.2020 06:01:10

19.01.2020 15:03:15

red

3 €

4

18.01.2020 06:02:20

18.01.2020 06:05:44

blue

6 €

 

Start_time and End_time define the time, on which the bid was placed/taken down.

Table sells:

Sell_id

Sell_time

Product_type

Price

1

18.06.2020 06:00:31

blue

6,50 €

2

18:06.2020 06:51:03

red

2,50 €

 

The sell_id and the bid_id have no relation with each other.

What I want to find out is, what is the maximum bid to the time we sold the product (how much more expensive could we sell). So if we take sell_id 1, it should check, which bids for this specific product were active during the sell_time (in this case bid_id 1 and 2) and give back the higher price (in this case bid_id 2).

So a simple IF(start_time < sell_time AND end_time > sell_time) would suffice, however I am struggling with creating an actual measure, since those 2 tables have no relation with each other.

I hope, this somehow explains my problem. I am grateful for ANY help you can provide. Thanks in advance!

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@Anonymous,

 

Try this measure:

 

Max Bid = 
VAR vProduct =
    MAX ( TableSells[Product_type] )
VAR vSellTime =
    MAX ( TableSells[Sell_time] )
VAR vTableBids =
    FILTER (
        ALL ( TableBids ),
        TableBids[Product_type] = vProduct
            && vSellTime >= TableBids[Start_time]
            && vSellTime <= TableBids[End_time]
    )
VAR vResult =
    MAXX ( vTableBids, TableBids[Price] )
RETURN
    vResult

 

DataInsights_0-1602815879310.png

 

In the sample data, I assumed the Sell_time month should be "01" instead of "06".





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
DataInsights
Super User
Super User

@Anonymous,

 

Try this measure:

 

Max Bid = 
VAR vProduct =
    MAX ( TableSells[Product_type] )
VAR vSellTime =
    MAX ( TableSells[Sell_time] )
VAR vTableBids =
    FILTER (
        ALL ( TableBids ),
        TableBids[Product_type] = vProduct
            && vSellTime >= TableBids[Start_time]
            && vSellTime <= TableBids[End_time]
    )
VAR vResult =
    MAXX ( vTableBids, TableBids[Price] )
RETURN
    vResult

 

DataInsights_0-1602815879310.png

 

In the sample data, I assumed the Sell_time month should be "01" instead of "06".





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Wow thank you for the fast answer!

 

Thank you very much! This works perfectly and is way faster on big databases than other solutions i have tried!

 

Have a nice day!

 

PS: Yes, i meant sell_time month "01" 🙂

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.