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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
JamesB
New Member

Creatiing a calculated column of last date from a related table

Hi All,

First time post, so sorry for the newbie question but I did not see it when looking

I have a products table and a product sales table related 1:n on product number. I want to create a calculated column in the product table which grabs the last sale date for each product in the product sales table, is this possible and if so how?

My assumption is begining with related(lastdate('product Sales'[sold_date])), but this runs in to issues, any help would be much appreciated?
1 ACCEPTED SOLUTION
sdjensen
Solution Sage
Solution Sage

Hi,

 

You could try something like this.

 

LastSalesDate =
CALCULATE(
	MAX( 'product Sales'[sold_date] ),
	FILTER( 
		'product Sales',
		'product Sales[product number] = 'products table'[product number]
	)
)  
/sdjensen

View solution in original post

3 REPLIES 3
sdjensen
Solution Sage
Solution Sage

Hi,

 

You could try something like this.

 

LastSalesDate =
CALCULATE(
	MAX( 'product Sales'[sold_date] ),
	FILTER( 
		'product Sales',
		'product Sales[product number] = 'products table'[product number]
	)
)  
/sdjensen

Thanks for replying this worked, but an even easier solution in the end was a simple MAX (as you suggested) as a measure and then the end user tool would give the correct answer when teh measure was formatted as a date.

@JamesB - did you solve your problem?

/sdjensen

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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