Forum Discussion
Anonymous
5 years agoNot applicable
Wrong outcome using DATEDIFF
In the screenshot below you can see my Power BI page. I want to calculate the days between two dates. I want to have the number of days from VALIDFROM to Tot Datum. But when the Tot Datum is not with...
mahoneypat
Microsoft Employee
5 years agoFor your syntax to work, either VALIDFROM is a measure or Tijd in Leedstand is a DAX column. I suspect the later. Your columns probably should be done as measures instead. But for the one you are trying to respond to the slicer, you could use this measure expression
Tijd in Leegstand =
VAR maxdate =
MAX ( 'Dim_Datum Periode'[Datum] )
VAR totdatumdate =
MAX ( 'PMContract'[Tot Datum] )
VAR comparedate =
IF (
maxdate > totdatumdate,
totdatumdate,
maxdate
)
RETURN
DATEDIFF (
MAX ( 'PMContract'[VALIDFROM] ),
comparedate,
DAY
) + 1
Regards,
Pat