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
paulsnet1986
Helper I
Helper I

Historical Record Counts Using Date Table Help

I have a table with records that have a Start_Date and End_Date. They are connected to a master date table with an active connection to the Start_Date and an inactive connection to the End_Date.

 

I'm trying to create a matrix with yyyyMM in the columns and DISTINCTCOUNT of the records, where the record is counted in a given month if the Start_Date is less than or equal to the last day of a given month and the End_Date is greater than or equal to the first day of a given month.

 

I tried the following formula and got a blank result. Any help would be appreciated.

 

_Functional Location Net =
CALCULATE(DISTINCTCOUNT('Functional Location Master'[Functional Location]),
'Functional Location Master'[Functional Startup Date] <= SELECTEDVALUE('Date'[Date]),
'Functional Location Master'[Functional End Date Adjusted] >= SELECTEDVALUE('Date'[Date]))

 

 

paulsnet1986_0-1740500354423.png

 

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Try

_Functional Location Net =
VAR StartMonth =
    MIN ( 'Date'[Date] )
VAR EndMonth =
    MAX ( 'Date'[Date] )
VAR Result =
    CALCULATE (
        DISTINCTCOUNT ( 'Functional Location Master'[Functional Location] ),
        'Functional Location Master'[Functional Startup Date] <= EndMonth,
        'Functional Location Master'[Functional End Date Adjusted] >= StartMonth,
        REMOVEFILTERS ( 'Date' )
    )
RETURN
    Result

This will return any records where the start date is before the end of the month, including in prior months. If you want to exclude prior months then you can add additional logic.

View solution in original post

1 REPLY 1
johnt75
Super User
Super User

Try

_Functional Location Net =
VAR StartMonth =
    MIN ( 'Date'[Date] )
VAR EndMonth =
    MAX ( 'Date'[Date] )
VAR Result =
    CALCULATE (
        DISTINCTCOUNT ( 'Functional Location Master'[Functional Location] ),
        'Functional Location Master'[Functional Startup Date] <= EndMonth,
        'Functional Location Master'[Functional End Date Adjusted] >= StartMonth,
        REMOVEFILTERS ( 'Date' )
    )
RETURN
    Result

This will return any records where the start date is before the end of the month, including in prior months. If you want to exclude prior months then you can add additional logic.

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors