Forum Discussion
TimmK
3 years agoHelper IV
How to Dynamically Subtract Variable Days?
For simplicity I have a table with the three columns "Order Key", "Date" and "Days". I would like to use a DAX measure (or if this is not possible a calculated column) to subtract the days from t...
- 3 years ago
You could create a measure like
Adjusted date = VAR ReferenceDate = SELECTEDVALUE ( 'Table'[Date] ) VAR ReferenceDays = SELECTEDVALUE ( 'Table'[Days] ) VAR BaseDate = ReferenceDate - ReferenceDays VAR Result = SWITCH ( WEEKDAY ( BaseDate ), 1, BaseDate - 2, 7, BaseDate - 1, BaseDate ) RETURN Result
TimmK
3 years agoHelper IV
This seems to have the correct result. Yet, when I add the measure to the table it loads a very long time. In another table (that has some more rows, 15 to be exact) it does not work at all, after a while I receive the error message "There's not enough memory to complete this operation.".
Is there any possibility to improve the performance or maybe another solution?
johnt75
3 years agoSuper User
I think you could adapt the technique from https://www.youtube.com/watch?v=2HkBbqxBzF0