Forum Discussion
How to link data from two table with Formula requirement
- 6 years ago
Hi,
you can do this with both Power Query and Dax.
Power query:
Merge the Expense-table with the Travel-table on Employee ID. Create a column which is equal to 1 when Expense Date between Departure date and Return date, and filter this column on 1. Remove all columns except Employee ID, Expense Date, Nature and Travel ID
Dax:
New column the Expense-table:TravelIdDax = CALCULATE ( SELECTEDVALUE ( Travel[Travel ID] ); FILTER ( Travel; Expanse[Employee ID] = Travel[Employee ID] && Expense[Expense Date] >= Travel[Departure Date] && Expense[Expense Date] <= Travel[Return Date] ) )
If you want to create a relationship between the tables on Travel ID, you should use power query, otherwise you will get a circular dependency error
Hi,
you can do this with both Power Query and Dax.
Power query:
Merge the Expense-table with the Travel-table on Employee ID. Create a column which is equal to 1 when Expense Date between Departure date and Return date, and filter this column on 1. Remove all columns except Employee ID, Expense Date, Nature and Travel ID
Dax:
New column the Expense-table:
TravelIdDax =
CALCULATE (
SELECTEDVALUE ( Travel[Travel ID] );
FILTER (
Travel;
Expanse[Employee ID] = Travel[Employee ID]
&& Expense[Expense Date] >= Travel[Departure Date]
&& Expense[Expense Date] <= Travel[Return Date]
)
)
If you want to create a relationship between the tables on Travel ID, you should use power query, otherwise you will get a circular dependency error
Hi,
Thank you very much for your quick answer ! You solved my problem :)