Forum Discussion
Sbudd
Helper II
4 years agoJoining on date range
Hi I have 2 tables which i would like to join if within a date range. Table 1 is a Orders, Account name, date, units and value ordered. Plus a measure to calculate Rev. Table 2 is AM Table, s...
- 4 years ago
As long as there is no overlap between different people for the same account then you can add a column to Sales as
AM Name = var currentAccount = Sales[Account] var currentDate = Sales[Date] return CALCULATETABLE( SELECTCOLUMNS('AM Table', "AM Name", 'AM Table'[Name]),'AM Table'[Account] = currentAccount, 'AM Table'[Start] <= currentDate && 'AM Table'[End] > currentDate )
Sbudd
Helper II
4 years agoThanks for that John, As my real life scenario is far more complex than the above, your solution works great for the simplified version but not fully. Is there a way of pulling in the Name into the Sales table so i can use the other dimensions/metrics?
I.e Is there a way of just adding the AM name to the sales table?
johnt75
Super User
4 years agoAs long as there is no overlap between different people for the same account then you can add a column to Sales as
AM Name =
var currentAccount = Sales[Account]
var currentDate = Sales[Date]
return CALCULATETABLE( SELECTCOLUMNS('AM Table', "AM Name", 'AM Table'[Name]),'AM Table'[Account] = currentAccount,
'AM Table'[Start] <= currentDate && 'AM Table'[End] > currentDate )