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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
ALDOBES
Frequent Visitor

DAX Calc Column - Pulling a date from a different table with different last value and match criteria

So this seems like it should be simple... but I've scrambled my brain so here goes for a first post.

I have 2 Server DB tables (call them ref 2 like the below and ref 1 just containing account IDs).

For reference purposes I want to add a column to ref 1 showing

'Ref 2'[Op Date]
for the MAX 'Ref 2'[EntryID]
where 'Ref 2'[AccountID] matches the SelectedValue 'Ref 1'[AccountID].

The 2 tables are linked by Account ID, Many to Many as there are unfortunately Duplicate entries in Ref 1 and filter both ways.

I've tried a number of variations of the below but I can't unscramble my head and it has all returned #error to now.
Last Entry Op Date = calculate(
'Ref 2'[Op Date],
MAX('Ref 2'[Entry ID],
'Ref 2'[AccountID] = Selectedvalue('Ref 1'[AccountID])

Op DateEntry IDAccountID
16/07/2023 14:47:359774762007379274703
18/07/2023 00:34:219289141904756752772
27/07/2023 06:15:109172141119358622046
13/07/2023 12:00:139070032290855267343
21/07/2023 09:55:448872421424686439489
15/07/2023 17:57:478222982007379274703
21/07/2023 08:07:278205391430816835926
17/07/2023 06:30:528032371952679035307
18/07/2023 23:59:417884961904756752772
28/07/2023 05:17:587475611119358622046
18/07/2023 22:56:346767361904756752772
15/07/2023 12:41:156343472007379274703
18/07/2023 01:54:305254841904756752772
28/07/2023 14:23:355101211060578812721
22/07/2023 15:52:065012051424686439489
24/07/2023 02:31:544946701307264180043
28/07/2023 12:39:254946291060578812721
14/07/2023 22:17:134851052290855267343
17/07/2023 19:57:224543651952679035307
20/07/2023 21:48:104336311542795844048
26/07/2023 12:52:344020461140524088630
21/07/2023 22:57:083913101424686439489
19/07/2023 23:19:383428241542795844048
24/07/2023 22:57:242566981142365672705
17/07/2023 12:52:571467051952679035307
25/07/2023 11:06:571401181142365672705
26/07/2023 00:50:121292471140524088630
23/07/2023 14:07:201140291368747587467
19/07/2023 03:46:591078281631713953852


For Clarification for the shown examples I'd like to see...

AccountIDLast Entry Created Date
229085526734313/07/2023 12:00:13
229085526734313/07/2023 12:00:13
200737927470316/07/2023 14:47:35
200737927470316/07/2023 14:47:35
200737927470316/07/2023 14:47:35
195267903530717/07/2023 06:30:52
195267903530717/07/2023 06:30:52
195267903530717/07/2023 06:30:52
190475675277218/07/2023 00:34:21
190475675277218/07/2023 00:34:21
190475675277218/07/2023 00:34:21
190475675277218/07/2023 00:34:21
163171395385219/07/2023 03:46:59
154279584404820/07/2023 21:48:10
154279584404820/07/2023 21:48:10
143081683592621/07/2023 08:07:27
142468643948921/07/2023 09:55:44
142468643948921/07/2023 09:55:44
142468643948921/07/2023 09:55:44
136874758746723/07/2023 14:07:20
130726418004324/07/2023 02:31:54
114236567270524/07/2023 22:57:24
114236567270524/07/2023 22:57:24
114052408863026/07/2023 12:52:34
114052408863026/07/2023 12:52:34
111935862204627/07/2023 06:15:10
111935862204627/07/2023 06:15:10
106057881272128/07/2023 14:23:35
106057881272128/07/2023 14:23:35
1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @ALDOBES 

 

You can create a calculated column with below DAX in "Ref 1" table. 

Last Entry Created Date = 
var _maxEntry = CALCULATE(MAX('Ref 2'[Entry ID]),'Ref 2'[AccountID]=EARLIER('Ref 1'[AccountID]))
return
CALCULATE(MAX('Ref 2'[Op Date]),'Ref 2'[Entry ID]=_maxEntry)

vjingzhang_0-1683013934901.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

 

View solution in original post

3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hi @ALDOBES 

 

You can create a calculated column with below DAX in "Ref 1" table. 

Last Entry Created Date = 
var _maxEntry = CALCULATE(MAX('Ref 2'[Entry ID]),'Ref 2'[AccountID]=EARLIER('Ref 1'[AccountID]))
return
CALCULATE(MAX('Ref 2'[Op Date]),'Ref 2'[Entry ID]=_maxEntry)

vjingzhang_0-1683013934901.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

 

Cheers @v-jingzhang !!!

ALDOBES
Frequent Visitor

Sorry. First table should look like this.

ALDOBES_0-1681991025480.png

Second like this

ALDOBES_1-1681991065375.png

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.