Forum Discussion
Green_Cloud
4 years agoHelper I
Assigning Codes based on Date Range
Altruists,
I need DAX to assign sales code as a new column based on the date ranges (Sales Start and End date) as follows-
Can you please share the DAX?
If you know that you won't have any overlapping date ranges then you could do something like
Sales Code = var currentSaleDate = 'Sales Table'[Sale date] return SELECTCOLUMNS( FILTER( 'Lookup table', 'Lookup table'[Sales Start Date] <= currentSaleDate && 'Lookup table'[Sales End Date] >= currentSalesDate), "@val", 'Lookup table'[Sales Code])
2 Replies
- johnt75Super User
If you know that you won't have any overlapping date ranges then you could do something like
Sales Code = var currentSaleDate = 'Sales Table'[Sale date] return SELECTCOLUMNS( FILTER( 'Lookup table', 'Lookup table'[Sales Start Date] <= currentSaleDate && 'Lookup table'[Sales End Date] >= currentSalesDate), "@val", 'Lookup table'[Sales Code])- Green_CloudHelper I
Thank you!