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

Finding amount based on latest date in 2nd table

Hello everyone,

 

I am new to Power BI and this is my first post on this community.

 

Here is my Q.

 

I have two tables

 

Table1   Table 2  
 IDResult  IDAmountDate
1  15Wednesday, January 04, 2017
2  110Thursday, January 05, 2017
3  215Friday, January 06, 2017
4  25Saturday, January 07, 2017
5  325Sunday, January 08, 2017
   450Monday, January 09, 2017
   560Tuesday, January 10, 2017
   5100Wednesday, January 11, 2017
      
      
Result into Table1    
 IDResult    
110    
25    
325    
450    
5100    
1 ACCEPTED SOLUTION

10 REPLIES 10
Phil_Seamark
Employee
Employee

Hi @fahadarshad

 

This worked for me on your test data.  I created the following calculation, which takes advantage of the relationship between Table1 and Table2

 

My Amount = CALCULATE(
			MAX('Table2'[Amount]),
			LASTDATE('Table2'[Date])
			)

myAmount.png

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Hi Phil

 

I am getting an error saying "a date column containing duplicate dates was specified in the call to the function."

Are you loading the measure on your sample dataset, or on a larger dataset?

 

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Hi Phil

 

It is on a larger dataset.

Hi @fahadarshad

 

Any chance you can share a bigger sample so I can try and replicate?


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

I can share with you the entire dataset. Here you go

 

https://www.dropbox.com/s/kxhsssa9wp0tpyt/Book1.xlsx?dl=0

 

This doesnt throw an error.

 

My Amount = CALCULATE(
			MAX('Table2'[Amount - Quote]),
			filter('Table2',
				'Table2'[Created On]=MAX('Table2'[Created On])
				)
			)

 

Just checking if it is right


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

it doesn't throw an error, but doesnt throw any values out either.

Hi @fahadarshad

 

Please see if this PBIX file works for you

 

https://wgtnpowerbi-my.sharepoint.com/personal/phil_wgtnpowerbi_onmicrosoft_com/_layouts/15/guestacc...


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Thank you!!!!!

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.