Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Active Contacts Over time.

Hi there.  I'm having an issue plotting a graph of number of active members over time. 

Its very similar to this topic, but they're getting different results:

Solved: Active Clients over time - Microsoft Power BI Community

 

For some reason my table seems to show the numbers incorrectly.  for example in april this year its saying only 30 people are active, but I can see that's not correct by looking at the table.  The number should be more like the Total figure of 700k, as that's (ballpark) the rough number of actives on any given day.

 

My measure (that appears to work) looks like this:

 

CORRECT Active Members =
CALCULATE(COUNTROWS('CE vwContact (2)'),
    FILTER( VALUES('CE vwContact (2)'[Rics_ElectionDate]), 'CE vwContact (2)'[Rics_ElectionDate] <= MAX('-Calendar'[Date])),
    FILTER( VALUES('CE vwContact (2)'[Rics_LapsedDate]), OR('CE vwContact (2)'[Rics_LapsedDate] >= MIN('-Calendar'[Date]),
ISBLANK('CE vwContact (2)'[Rics_LapsedDate]))))
 
The election date and lapsed date ni my vwContact table is linked to the 'Date' field in the Calendar field.
With a one to many relationship from the calendar into the contacts database.
 
Can anyone work out why the numbers aren't showing up correctly?  I want it to show only the contacts that are active on those dates.
 
Thank
  • johnt75's avatar
    johnt75
    4 years ago

    Delete the first reference to election date on line 3, you only need to compare that to the MAX.

7 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Looking at the numbers it looks like the contacts are only being counted once, in the first date they appear... but they should be counted on every date that they're active.  I'm not sure why this isn't happening because I think my measure is correct?  I don't have a distinct count in it...?

  • I'm guessing that the relationship between calendar table and election date is active, and that is causing the filtering to the first occurence.

    Try

    CORRECT Active Members =
    CALCULATE (
        COUNTROWS ( 'CE vwContact (2)' ),
        'CE vwContact (2)'[Rics_ElectionDate] <= MAX ( '-Calendar'[Date] ),
        OR (
            'CE vwContact (2)'[Rics_LapsedDate] >= MIN ( '-Calendar'[Date] ),
            ISBLANK ( 'CE vwContact (2)'[Rics_LapsedDate] )
        ),
        REMOVEFILTERS ( '-Calendar'[Date] )
    )
    • Anonymous's avatar
      Anonymous
      Not applicable

      I've got 2 connectsionfr from the calendar into the contact,

      One on Date (from the Calendar table) into Lapsed Date in the Contacts table (this is active)

      and the other from Date (calendar table) into election date in the contacts table (this isn't active as it wont let me have 2 active connections)

      • johnt75's avatar
        johnt75
        Super User

        You need to add the REMOVEFILTERS as I posted, that will remove the effect of the active relationship with the lapsed date, as that is incorrectly filtering the rows in this instance.