Forum Discussion
Count unique values present across months
- 3 years ago
kinkate18nic
Yes, it will be counted as 1. But you can filter it out using either of the folowing depending on whether the blank is acually BLANK () or just empty string ""Unique AlertID Count = VAR CurrentDate = MIN ( 'Table'[Event Date] ) VAR CurrentIDs = FILTER ( VALUES ( 'Table'[AlertID] ), 'Table'[AlertID] <> BLANK () ) VAR PreviousIDs = DISTINCT ( SELECTCOLUMNS ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Event Date] < CurrentDate ), "AlertID", 'Table'[AlertID] ) ) RETURN COUNTROWS ( EXCEPT ( CurrentIDs, PreviousIDs ) ) Unique AlertID Count = VAR CurrentDate = MIN ( 'Table'[Event Date] ) VAR CurrentIDs = FILTER ( VALUES ( 'Table'[AlertID] ), 'Table'[AlertID] <> "" ) VAR PreviousIDs = DISTINCT ( SELECTCOLUMNS ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Event Date] < CurrentDate ), "AlertID", 'Table'[AlertID] ) ) RETURN COUNTROWS ( EXCEPT ( CurrentIDs, PreviousIDs ) )
Hi kinkate18nic
Please try
Unique AlertID Count =
VAR CurrentDate =
MIN ( 'Table'[Event Date] )
VAR CurrentIDs =
VALUES ( 'Table'[AlertID] )
VAR PreviousIDs =
DISTINCT (
SELECTCOLUMNS (
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Event Date] < CurrentDate ),
"AlertID", 'Table'[AlertID]
)
)
RETURN
COUNTROWS ( EXCEPT ( CurrentIDs, PreviousIDs ) )
Thank for the measure, this seems to be working fine. Just a hiccup, suppose if there is a blank alertID in a month, will that cause the count of the month to increase? I was testing this out in my dataset, for march i have actual 4 unique alertids and there is one entry with eventid but alert id blank. for march this measure is providing 5 as the count.
- tamerj13 years ago
Community Champion
kinkate18nic
Yes, it will be counted as 1. But you can filter it out using either of the folowing depending on whether the blank is acually BLANK () or just empty string ""Unique AlertID Count = VAR CurrentDate = MIN ( 'Table'[Event Date] ) VAR CurrentIDs = FILTER ( VALUES ( 'Table'[AlertID] ), 'Table'[AlertID] <> BLANK () ) VAR PreviousIDs = DISTINCT ( SELECTCOLUMNS ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Event Date] < CurrentDate ), "AlertID", 'Table'[AlertID] ) ) RETURN COUNTROWS ( EXCEPT ( CurrentIDs, PreviousIDs ) ) Unique AlertID Count = VAR CurrentDate = MIN ( 'Table'[Event Date] ) VAR CurrentIDs = FILTER ( VALUES ( 'Table'[AlertID] ), 'Table'[AlertID] <> "" ) VAR PreviousIDs = DISTINCT ( SELECTCOLUMNS ( FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Event Date] < CurrentDate ), "AlertID", 'Table'[AlertID] ) ) RETURN COUNTROWS ( EXCEPT ( CurrentIDs, PreviousIDs ) )- kinkate18nic3 years agoFrequent Visitor
yep, works perfectly, thanks a lot for your help