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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Getting max and min date from subset of data - DAX

I have a dataset that I've summarized by card, reg date, and first purchase date.  The card will usually repeat in this data.  I want to create a calculated column that flags the row as containing max purchase date among all values in the table with THAT current card number.

Here's one view where I'm filtering on a specific card:

 

ncrowder_0-1664383425940.png

Ideally, the first row would get a 1 in the maxreg row but because it's applying max to the whole table not just the rows with that card number there is a 0 because there are cards with later registration dates in the entire set of data.

 

I want to be able to essentially weed the entire table down (like a calculated table) to only a unique card number that corresponds to the latest reg and earliest purchase.  If there is a column that says if(maxreg && minpur, 1, 0) that would be easy to only include those values in any futher analysis.

3 REPLIES 3
VijayP
Super User
Super User

@Anonymous 

Just now I read your problem statement and understand you want a calculated column hence my earlier doesnt aply there!




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Anonymous
Not applicable

I'm a little confused wouldn't including all(tablename) do exactly what max(column) would do?  Or is this one of those context transition things?  In any case, if this is what you had in mind for the MaxReg column it returns an error:

 

MaxReg = if('Table'[Customer Reg Date]=calculate(max('Table'[Customer Reg Date],all('Table'))),1,0)
VijayP
Super User
Super User

@Anonymous 

Try this Calculate(max(column), all(tablename)) to get the relative max values 




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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