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
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
- Anonymous2 years agoNot applicable
Seems like that fixed it?
I'd also recommend making sure those different statements are on different rows in that measure (Shift + Enter). Future you will really appreciate it being easier to read 😉
- Anonymous2 years agoNot applicable
I'm fairly new to PowerBi, so I apologize in advance for the questions. March 24th is still showing only 3 active inmates, when there were approximately 350. Am I missing another step? Yes, thank you for that bit of advice regarding the shift+enter!
- Anonymous2 years agoNot applicable
Its not immediately obvious to me what other factor is coming into play here. I'm about to log off so i won't be back on until tomorrow. I'd manually look at your data and run through the code like you are the machine. Pick a date and manually set filters according to the rules in the code. Perhaps something obvious will stand out to you.