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