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
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
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.