Reputation: 907
Need help with DAX Syntax in what I am trying to accomplish. Here is what I have currently tried
Number of Months = ABS(DATEDIFF(myLeas[RENTDATE],TODAY(),Month))
The Problem is, in place of "Today" i need to pass the date coming from the Slicer on the visual. How do I do this?
Upvotes: 0
Views: 1414
Reputation: 2584
Since it is a date slicer, you probably have start and end dates. In this case SELECTEDVALUE
might not work. You could try using variables in this case:
Months =
VAR MAX_DATE = MAXX(ALLSELECTED(myLeas),myLeas[RentDate])
Return ABS(DATEDIFF(Table[RentDate],MAX_DATE,MONTH))
This should give the value you are looking for. Hope this helps.
Upvotes: 0
Reputation: 6940
Replace TODAY()
with:
SELECTEDVALUE ( Table[Column] )
where Table[Column] is the column you have put on the slicer.
So your measure will be:
Number of Months =
ABS (
DATEDIFF (
myLeas[RENTDATE],
SELECTEDVALUE ( Table[Column] ),
MONTH
)
)
Search for additional tips: capture slicer value pbi
For further tips:
https://powerpivotpro.com/2018/02/using-selectedvalues-capture-power-bi-slicer-selections/
Upvotes: 1