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
joshua1990
Post Prodigy
Post Prodigy

VLOOKUP with MAX

Hello everyone!

I have two tables:

tblOrder

OrderDateValue
100101.01.2020500
100201.01.2020 

 

tblWork

OrderSEQStateString
1001501AAA
1001502

BBB


Now I would like to add the first table a calculated column that shows me the String for the row of tblWork where SEQ & State = MAX

 

How would you do that?

3 REPLIES 3
Anonymous
Not applicable

// Please note I'm not using CALCULATE here
// because if the tblOrder table is big,
// it would be agonizingly slow.
[String] =
var __order = tblOrder[Order]
var __maxSEQ =
	MAXX(
		topn(1,
			filter(
				tblWork,
				tblWork[Order] = __order
			),
			tblWork[SEQ],
			DESC
		),
		tblWork[SEQ]
	)
var __maxState =
	MAXX(
		topn(1,
			filter(
				tblWork,
				tblWork[Order] = __order
				&&
				tblWork[SEQ] = __maxSEQ
			),
			tblWork[State],
			DESC
		),
		tblWork[State]
	)
var __string =
MAXX(
	filter(
		tblWork,
		tblWork[Order] = __order
		&&
		tblWork[SEQ] = __maxSEQ
		&&
		tblWork[State] = __maxState
	),
	tblWork[String]
)
return
	__string
	

 

Best

D

Thanks for your approach! Unfortunately, I get the following error:
Calculation error in measure YXX : A single value for column 'XX' cannot be determined in table 'XX'. This can happen when a measure formula references a column that contains many values ​​without specifying an aggregation such as 'min', 'max', 'count' or 'sum' to get a single result.

Anonymous
Not applicable

This is not a measure. It's a calculated column. This is what you asked for.

Best
D

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.