How do you get the month difference if the difference between two dates is less than a month?
Below is the DAX code that you can use to get more accurate figure for interval boundaries between dates. If you want to see the exact number it produces then reformat to decimal places and see how code behaves.
M_PY_Rate =
VAR startDate =
CALCULATE ( MIN ( dimDate[FullDate] ), ALLSELECTED ( dimDate[FullDate] ) )
VAR endDate =
CALCULATE ( MAX ( dimDate[FullDate] ), ALLSELECTED ( dimDate[FullDate] ) )
VAR diff =
( 1
* ( endDate - startDate) )
/ DAY ( EOMONTH ( endDate, 0 ) )
--DATEDIFF ( endDate, startDate, MONTH ) (Archived)
RETURN
CALCULATE (
[M_SI_RATE],
PARALLELPERIOD ( dimDate[FullDate], -(diff), MONTH )
)
No comments:
Post a Comment