Forum Discussion
count row on condition
- 3 years ago
this solved it:
Active assets = var endDate = MAX(DateTime[Date]) var result = CALCULATE( COUNTROWS('fleet'), REMOVEFILTERS('DateTime'), 'fleet'[in use] <= endDate, 'fleet'[out of use] > endDate || ISBLANK('fleet'[out of use]) ) return result
I don't understand what you mean. With the details you already provided, what rows are being counted and what rows are being excluded?
I'm starting to understand what goes wrong. In my model I have a relationship between the In use column and the date column of my datetime tabel. So when I create a barchart with the data on the x-axis, the data is automatically filtered. I only get to see the number of cars where the In Use data is the same as the X-axis label. I don't want that, for every label on the x-axis, I want to visualize the number of cars that are active (meaning a-axis label is between In Use and Out Of Use)
- AnthonyGenovese3 years ago
Resolver III
What about something like
CALCULATE( COUNTROWS('Fleet'), ALL(DateTable), 'Fleet'[In use ] <= today() && 'Fleet'[Out of use] >= today() )- brechtt3 years agoRegular Visitor
Now I have a constant value over the entire timerange, I suppose it's not filtering at all anymore. I don't understand the today(). It shouldn't be today(), it should be the month, year, ... of the x-axis
- AnthonyGenovese3 years ago
Resolver III
Then something like
var dateFilter=selectedvalue(dateTable[date])
var result= CALCULATE( COUNTROWS('Fleet'), ALL(DateTable), 'Fleet'[In use ] <= dateFilter && 'Fleet'[Out of use] >= dateFilter)
return result