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
Winter_king94
Helper I
Helper I

Custom column - return result of a field based on max date for each unique id

Hi, 

 

I am trying to create a column that populates the campaign name that has the max create date for each id. Below is an example of the data set and the ideal end result. There are some campaigns that have the same created date but a different time stamp as well. 

 

Winter_king94_0-1728602167267.png

 

I was able to make a measure that populated the campaign name correclty but am unable to figure out how to make a column that does the same.

 

Below is the measure I made:

Max CR Name = CALCULATE(FIRSTNONBLANK('campaignresponse'[Parent Campaign],1),
Filter('campaignresponse', 'campaignresponse'[createdon_CDT] = 'campaignresponse'[CR Max Date.MAX CR Date]))

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Winter_king94 ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create calculated columns.

 

Column = 
var _max_date=CALCULATE(MAX('Table'[Created Date]),FILTER('Table','Table'[ID]=EARLIER('Table'[ID])))
RETURN CALCULATE(MAX('Table'[Campaign Name]),FILTER('Table',[ID]=EARLIER('Table'[ID]) && [Created Date]=_max_date))
Column 2 = 
CALCULATE(MAX('Table'[Created Date]),FILTER('Table','Table'[ID]=EARLIER('Table'[ID])))

 

(3) Then the result is as follows.

vtangjiemsft_0-1728610114373.png

 

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Winter_king94 ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create calculated columns.

 

Column = 
var _max_date=CALCULATE(MAX('Table'[Created Date]),FILTER('Table','Table'[ID]=EARLIER('Table'[ID])))
RETURN CALCULATE(MAX('Table'[Campaign Name]),FILTER('Table',[ID]=EARLIER('Table'[ID]) && [Created Date]=_max_date))
Column 2 = 
CALCULATE(MAX('Table'[Created Date]),FILTER('Table','Table'[ID]=EARLIER('Table'[ID])))

 

(3) Then the result is as follows.

vtangjiemsft_0-1728610114373.png

 

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.