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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
cmac1
Regular Visitor

Max Bid

I am new to DAX and am trying to do something that I think should be fairly simple.  I have an auction table where each row is a unique bid for a specific item.  Each bid has its own unique id, bid amount, bidder id, and references the item that is being bid on.  I need to find the bidder with the maximum bid for each item.  Any suggestions on how I can do that?

2 ACCEPTED SOLUTIONS
v-shex-msft
Community Support
Community Support

Hi @cmac1,


You can simple use summarize function to get the max bid amount of each item:

 

Table 2 = SUMMARIZE(Sheet1,[bidder id],"Max Bid",MAX(Sheet1[bid amount]))

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

Hey,

 

in this example I used Power Query to find the max amount for an item, I started with this table (fact)

 

table base.png

 

If you open the query editor and look at the query for the the table fact, you will see a step called "Group Rows (to be deleted)", here I used "Transform - Group By". You can delete this step if you want, it is used just for demonstration in this example :-):

 

grouping base.png 

 

If you have a look at the Formula Bar you will see this:

= Table.Group(#"Changed Type", {"itemid"}, {{"groupIndex", each _, type table}})

Here you will find " each _" the underscore represents each row of the base table, if you look at the step "Grouped Rows" you will see that I have replaced the underscore with a nested function call "Table.AddIndexColumn( Table.Sort(...))". Be aware that you have to replace the underscore in the Formula Bar. If you did the replacement, the grouping dialog will not reappear.


This tweaking is necessary to group by itemid but not to loose the column someoneid (in SQL Server you achieve this by using windowing functions (aggregating without loosing the detail rows).

 

This nested function call creates an IndexColumn. The Index restarts in each group. The function Table.Sort() sorts the rows in each group in descending order by the column amount

{{"amount", 1}}

 the 1 represents descending order whereas 0 means ascending order.

 

Than I

  • expanded the table,
  • renamed the column
  • filtered the rows where the column value is 1
  • merged the table with the table "someone" using the column someoneid to retrieve the value of the column someone

Hope this helps 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

6 REPLIES 6
v-shex-msft
Community Support
Community Support

Hi @cmac1,


You can simple use summarize function to get the max bid amount of each item:

 

Table 2 = SUMMARIZE(Sheet1,[bidder id],"Max Bid",MAX(Sheet1[bid amount]))

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thank you.  I realized that I needed to use Power Query instead of DAX.  So my formula ended up like this:

 

= Table.Group(#"StepNumber1", {"Auction Items"}, {{"Max Bid", each List.Max([Bid Price]), type number}, {"# of Bids", each Table.RowCount(_), type number}})

 

The results are accurate but I am missing an important piece.  I need to know who the Max Bidder is.  I have the Max Bid amount but I don't know who bidder for that amount was.  The bidder ID is in my table I just need to make it visible in this table.  Any ideas?

Hey,

 

in this example I used Power Query to find the max amount for an item, I started with this table (fact)

 

table base.png

 

If you open the query editor and look at the query for the the table fact, you will see a step called "Group Rows (to be deleted)", here I used "Transform - Group By". You can delete this step if you want, it is used just for demonstration in this example :-):

 

grouping base.png 

 

If you have a look at the Formula Bar you will see this:

= Table.Group(#"Changed Type", {"itemid"}, {{"groupIndex", each _, type table}})

Here you will find " each _" the underscore represents each row of the base table, if you look at the step "Grouped Rows" you will see that I have replaced the underscore with a nested function call "Table.AddIndexColumn( Table.Sort(...))". Be aware that you have to replace the underscore in the Formula Bar. If you did the replacement, the grouping dialog will not reappear.


This tweaking is necessary to group by itemid but not to loose the column someoneid (in SQL Server you achieve this by using windowing functions (aggregating without loosing the detail rows).

 

This nested function call creates an IndexColumn. The Index restarts in each group. The function Table.Sort() sorts the rows in each group in descending order by the column amount

{{"amount", 1}}

 the 1 represents descending order whereas 0 means ascending order.

 

Than I

  • expanded the table,
  • renamed the column
  • filtered the rows where the column value is 1
  • merged the table with the table "someone" using the column someoneid to retrieve the value of the column someone

Hope this helps 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

That worked great!  Thank you!

cmac1
Regular Visitor

I was able to get the formula setup using DAX also.  

 

BidSummary = SUMMARIZE(AuctionBids,AuctionBids[Auction Items],"Max Bid", MAX(AuctionBids[Bid Price]),"# of Bids",COUNT(AuctionBids[Bidder]))

 

But I have the same problem:  I also need to know who the winning bidder was?  I have the bidder ID in another table, I just need to have it available in this table.  Any ideas?

Anonymous
Not applicable

Hi @cmac1,

 

You can create a calculated column like below:

 

is highest bid = IF(
	RANKX(
		FILTER(
			data, EARLIER(data[item id])=data[item id]
		),
		data[bid amount],,
		DESC
	) = 1,
	1,
	0
)

This column will contain 1 for the highest bid for each individual item id.

 

HTH,

Pawel

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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