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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
jkoclejda
Helper I
Helper I

LOOKUPVALUE with multiple conditions in one table

Hi! I'm stuck and would appreciate a hint on how to make the column described below or a link to a thread with a solution.

 

I have a table with the "journey" of products within the warehouse - from delivery to dispatch in the order. Example data:

type_transferid_locationid_productid_dispatchdate_transferdispatch_origin
dispatch29876446606-03-2023 05:00:00123
drop_product29876446605-03-2023 08:20:002
get_product1239876446605-03-2023 08:00:00123
drop_product1239876 01-01-2023 11:35:00 
get_product19876 01-01-2023 11:30:00 
delivery19876 01-01-2023 11:00:00 

 

The bold column is the effect I would like to achieve. I would like to insert the value from the "id_location" column from the "type_transfer" = "get_product" rows to the "type_transfer" = "dispatch" rows. For both rows, the value of the "id_dispatch" and "id_product" columns must be the same. In addition, it should be the first value (based on the "data_transfer" column) - sometimes this product route can be longer, and I want its original location. 

 

For the rest of rows value should stay the same as in "locaion_id" column

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Try

dispatch_origin = 
VAR DispatchOrigin =
MINX(
	CALCULATETABLE( TOPN( 1, 'Table', 'Table'[date_transfer], ASC ),
		ALLEXCEPT( 'Table', 'Table'[id_dispatch], 'Table'[id_product] ),
		'Table'[type_transfer] = "get_product"
	),
	'Table'[id_location]
)
RETURN IF( 'Table'[type_transfer] = "dispatch", DispatchOrigin, 'Table'[id_location]) 

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

Try

dispatch_origin = 
VAR DispatchOrigin =
MINX(
	CALCULATETABLE( TOPN( 1, 'Table', 'Table'[date_transfer], ASC ),
		ALLEXCEPT( 'Table', 'Table'[id_dispatch], 'Table'[id_product] ),
		'Table'[type_transfer] = "get_product"
	),
	'Table'[id_location]
)
RETURN IF( 'Table'[type_transfer] = "dispatch", DispatchOrigin, 'Table'[id_location]) 

It works perfect! Thank you so much!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors