Forum Discussion
Dax Measurement Assistance
- Anonymous2 years ago
RossEdwards,
I ended up creating the following measurement on my data table:
ActiveInmatesCount =VAR CurrentDate = MAX('DimDate'[Date])RETURNCALCULATE(DISTINCTCOUNT('PrevFiveYrsJailing'[Booking#]),FILTER('PrevFiveYrsJailing','PrevFiveYrsJailing'[BookingDate] <= CurrentDate &&(ISBLANK('PrevFiveYrsJailing'[ReleaseDate]) ||'PrevFiveYrsJailing'[ReleaseDate] > CurrentDate)))I was getting the same result where the amounts were not as close to the actual numbers I have. I ended up linking this data table to a date table and making that relationship inactive. Once I made the relationship inactive between the two tables, the data appears to more accurate. I'm not sure why the inactive relationship worked, but it did. I wanted to thank you for your time and assistance, much appreciated!Alvina
Making some guesses about your dataset but this is what came to mind for me. Use this measure on a visual and it will take the last date in the context. If its a monthly table, it will be the date at the end of the month. If its a daily table, it will be daily.
Daily Count = var contextDate = MAX('DateTable'[Date])
var output = CALCULATE(
COUNTROWS('Inmates'),
ALL('Inmates'),
FILTER(
'Inmates',
'Inmates'[Booking Date] <= contextDate &&
'Inmates'[Release Date] >= contextDate
)
)
RETURN
output
Thank you for the prompt reply. This is the output. I was hoping to get a TOTAL count of currently incarcerated inmates, per day. For example on 3/23 there would have been approximately 350 inmates in jail, that have been been booked in within my time range and have not been released (time range is 5yrs back from current date).
- Anonymous2 years agoNot applicable
I suspect your issue is that you have used "Booking Date" in your visual. Replace that with the "Date" column from your Calendar table.
- Anonymous2 years agoNot applicable
Thanks for that information, I have now changed it to the Date of the Date Table. With the same result. I appreciate the assistance you've provided thus far!
- Anonymous2 years agoNot applicable
Thats really odd. Lets test if its unexpected behaviour caused by the filter function. Try this version:
Daily Count = var contextDate = MAX('DateTable'[Date]) var output = CALCULATE( COUNTROWS('Inmates'), ALL('Inmates'), 'Inmates'[Booking Date] <= contextDate, 'Inmates'[Release Date] >= contextDate ) RETURN output