relative dates
1 TopicCan this DAX measure for calculating relative dates be simplified?
Below is some DAX code I've written to calucalte a relative date. The user selects a date from a ReferenceDate calendar, this is separate from all other tables. [Max Quarter] calculates the reference date we're looking at. [IRR Date] then calculated relative dates based on the [Max Quarter] and a table called 'Trailing IRR' (screen shot attached). Have I over complicated the [IRR Date] measure?? Is there anything I can do to improve these measures? Let me know if I haven't explained it well. Max Quarter = SELECTEDVALUE( ReferenceDate[Quarter end date], CALCULATE( MAX('Calendar'[Quarter end date]), ALLSELECTED('Calendar'))) IRR Date = VAR TrailingDate = IF( SELECTEDVALUE('Trailing IRR'[Time Period])="3 Month", CALCULATE( MAX('Calendar'[Date]), PREVIOUSQUARTER( CALCULATETABLE( VALUES('Calendar'[Date]), FILTER(ALL('Calendar'), 'Calendar'[Date]=[Max Quarter])))), DATE( YEAR([Max Quarter])-SELECTEDVALUE('Trailing IRR'[Year]), MONTH([Max Quarter]), DAY([Max Quarter]))) RETURN IF( TrailingDate=[Max Quarter], BLANK(), TrailingDate)Solved2.5KViews1like3Comments