Forum Discussion
COUNTROWS + FILTER and include zero values
I am trying to use a filtered row count, but it's not displaying rows resulting in zero rows counted.
Here is my measure formula:
I've given up on trying to get a measure to work and decided to just count it with an M query.
10 Replies
- Greg_Deckler
Community Champion
Perhaps
device_threats = VAR __Count = COUNTROWS(FILTER('ThreatOccurrencesInTimeframe', CONTAINS('DevicesOnline', [id], 'ThreatOccurrencesInTimeframe'[device_id])))
RETURN
IF(ISBLANK(__Count),0,__Count)- dte-chris
Helper I
Greg_Deckler That didn't seem to change anything.
- Greg_Deckler
Community Champion
Try clicking on your column in Values area and choose "Show items with no data"?
- kentyler
Solution Sage
Do you have a relationship in your data model between ThreatOccurrencesInTimeframe and DevicesOnline ?
- dte-chris
Helper I
az38 Sorry, maybe I should have written that better. I do have a relationship. What's happening with the +0 is when I do that, the DevicesOnline starts ignoring filtering when I click on a related parent record. With my first query, everything works except rows with zeros are not displayed, and they get filtered when I click on a parent record in the report. With my second query, my DevicesOnline table in the report displays the entire table at all times, not just the ones related to the selected parent.
- lightsquaredNew Member
I found this to work:
CCV Count =IF (CALCULATE( COUNT ( 'ALT Monthly Critical Control Data'[Overdue CCV] ), 'ALT Monthly Critical Control Data'[Asset Status] = "ACTIVE",'ALT Monthly Critical Control Data'[Overdue CCV] < 0,'ALT Monthly Critical Control Data'[RMM Status] = BLANK()) = BLANK(),0,CALCULATE( COUNT ( 'ALT Monthly Critical Control Data'[Overdue CCV] ), 'ALT Monthly Critical Control Data'[Asset Status] = "ACTIVE",'ALT Monthly Critical Control Data'[Overdue CCV] < 0,'ALT Monthly Critical Control Data'[RMM Status] = BLANK()))It essentailly performs a count on filtered data and if the value is BLANK() then replace with a 0 else peform the count on filtered data normally.