Forum Discussion
User Input Date slicer - Date difference
Hi team,
Would need your help in fixing this scenario.
I need to create a table which has many measures, most of these measures are dependant on a date selection.
I have created a date table >DATE = CALENDARAUTO(), which gives me all the dates which are present in the data.
Now if the user selects a date i want that to get subtracted from the 'Acquisition date' date column to give the 'Date difference'.
I have the same scenario in my tableau report where i can select dynamic dates from a filter and subtract the same with the 'Acquisition date' column to get the 'Date difference'. Need to acheive the same in Power BI too.
eg: SELECTEDVALUE(DATEMASTER[DATE],0) - (TABLE['Acquisition Date']), i am not getting the desired result here.
Any support is much appreciated.
- Anonymous3 years ago
Hi Anonymous ,
Please have a try.
Selected Date = SELECTEDVALUE(DATEMASTER[DATE], BLANK())This will return the selected date from the 'DATEMASTER' table, or a blank value if no date is selected.
Create a calculated column in your data table that subtracts the 'Acquisition date' column from the selected date measure.
Date difference = DATEDIFF([Acquisition date], [Selected Date], DAY)This will return the number of days between the 'Acquisition date' and the selected date. Make sure that the 'Acquisition date' column and the 'DATEMASTER' table are properly related in your data model. Also, make sure that the 'Acquisition date' column is in date format.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ RongtieIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous3 years ago
Hi Anonymous , Thanks for the detailed solution.
I was able to find the solution with this dax formula.
Date Diff = DATEDIFF(MAX('Table'[Acquisition Date]),SELECTEDVALUE(DateMaster[Date]),DAY).
2 Replies
- AnonymousNot applicable
Hi Anonymous ,
Please have a try.
Selected Date = SELECTEDVALUE(DATEMASTER[DATE], BLANK())This will return the selected date from the 'DATEMASTER' table, or a blank value if no date is selected.
Create a calculated column in your data table that subtracts the 'Acquisition date' column from the selected date measure.
Date difference = DATEDIFF([Acquisition date], [Selected Date], DAY)This will return the number of days between the 'Acquisition date' and the selected date. Make sure that the 'Acquisition date' column and the 'DATEMASTER' table are properly related in your data model. Also, make sure that the 'Acquisition date' column is in date format.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ RongtieIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
Hi Anonymous , Thanks for the detailed solution.
I was able to find the solution with this dax formula.
Date Diff = DATEDIFF(MAX('Table'[Acquisition Date]),SELECTEDVALUE(DateMaster[Date]),DAY).