Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
android1
Post Patron
Post Patron

Count how many in a point in time

Hi,

 

I have a table 'ClientsList' with columns 

ClientIDClientRefStartDateEndDateActiveYN
Adna yaxyx2293619/04/2018 Y
Agnzs Hznnzsszy1799331/01/201824/04/2018 00:00N
Axdan Cullzn2280727/02/2018 Y
Axdan O'Shza2179122/02/2018 Y

 

I need the number of ClienID who were Active on 1/1/2018.

 

I have come up with this Measure but it's returning zero results. 

 

Tot clients start of 2018 = CALCULATE(DISTINCTCOUNT(ClientsList[ClientRef]),FILTER(ClientsList,ClientsList[EndDate] >= DATE(2018,1,1)), ClientsList[StartDate] <= DATE(2017,12,31)) + CALCULATE(DISTINCTCOUNT(ClientsList[ClientRef]),FILTER(ClientsList,ClientsList[EndDate] = BLANK()),ClientsList[StartDate] <= DATE(2017,12,31)) - CALCULATE(DISTINCTCOUNT(ClientsList[ClientRef]),FILTER(ClientsList,ClientsList[EndDate] = BLANK()),ClientsList[StartDate] <= DATE(2018,1,1),ClientsList[ActiveYN] = "N") + 0

 

See attached sample data.

 

https://www.dropbox.com/s/r3mdt7wvg74z1m1/data.csv?dl=0

 

 

2 REPLIES 2
Anonymous
Not applicable

PLEASE, use this http://www.daxformatter.com/raw/ Smiley Happy

 

And try this:

 

Tot clients start of 2018 = 
CALCULATE (
    DISTINCTCOUNT ( ClientsList[ClientRef] );
    ClientsList[EndDate] >= DATE ( 2018; 1; 1 ) ; ClientsList[StartDate] <= DATE ( 2017; 12; 31 ))
    + CALCULATE (
        DISTINCTCOUNT ( ClientsList[ClientRef] );
        ClientsList[EndDate] = BLANK () ; ClientsList[StartDate] <= DATE ( 2017; 12; 31 ))
    - CALCULATE (
        DISTINCTCOUNT ( ClientsList[ClientRef] );
        ClientsList[EndDate] = BLANK () ; ClientsList[StartDate] <= DATE ( 2018; 1; 1 ) ; ClientsList[ActiveYN] = "N")
    + 0
Greg_Deckler
Super User
Super User

Perhaps take a look at these two Quick Measures that I created to deal with date range type of issues:

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.