Forum Discussion
Anonymous
1 year agoNot applicable
Calculating maximum time between two records
Hello, I have a dashboard that I use for statistics on incident reports. I use a measure to calculate the working days between today and the last incident posted in my database. Here's the measure...
- 1 year ago
Yea my bad, as _incidents is a virtual table inside the same expression, DAX expects column references without the table name.
If you want to also include the time between the last incident and today, we will have to add some more variables inside the measure. Just append this to the existing variables and replace the RETURN row:
VAR last_incident = MAXX( FILTER( Incident, Incident[TypeAccident] = "AT" ), Incident[DateAndTime] ) VAR last_vs_today = COUNTROWS( FILTER( Dates, Dates[Date] > last_incident && Dates[Date] <= TODAY() && WEEKDAY( Dates[Date], 2 ) < 6 ) ) RETURN MAX( _max, last_vs_today )
timalbers
1 year agoSkilled Sharer
Yea my bad, as _incidents is a virtual table inside the same expression, DAX expects column references without the table name.
If you want to also include the time between the last incident and today, we will have to add some more variables inside the measure. Just append this to the existing variables and replace the RETURN row:
VAR last_incident = MAXX( FILTER( Incident, Incident[TypeAccident] = "AT" ), Incident[DateAndTime] )
VAR last_vs_today =
COUNTROWS(
FILTER(
Dates,
Dates[Date] > last_incident &&
Dates[Date] <= TODAY() &&
WEEKDAY( Dates[Date], 2 ) < 6
)
)
RETURN MAX( _max, last_vs_today )
Anonymous
1 year agoNot applicable