Forum Discussion
music43
Advocate II
4 years agoStop measure results after a specific date
Hi I am playing with the PBI Desktop (finance) dummy data to try and learn DAX. I am trying to stop Sales PY measure from returning a result after the last Sale date. I am pretty certain this DAX...
- 4 years ago
Actually with my suggestion you should use MAX ( Date[Date] ) as condition not SELECTEDVALUE.
What is happening hear is that SELECTEDVALUE returns blank everywhere while MAX ( Sales[Date] ) returns blank when there is no sale which did the job (blank = blank). But it won't work if you are slicing by Date instead of MonthYear.
n8ball
Advocate I
4 years agoThis is the way I do it. Add a DatesInThePast True / False column to your Date Table.
Sales Amt PY =
CALCULATE (
[Sales Amt],
CALCULATETABLE (
SAMEPERIODLASTYEAR ( 'Date'[Date] ),
'Date'[DatesInThePast] = TRUE
)
)
- n8ball4 years ago
Advocate I
If you want to know more about why I'm using this pattern check out this very good article from SQLBI: Hiding future dates for calculations in DAX - SQLBI