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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
Community Champion
Community Champion

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



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.