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
Anonymous
Not applicable

Count values in specified date range

Hello,

 

I'm trying to create a table similar to the below:

eli_n_0-1672776003903.png

I am having some issues counting the values in between a specific date range. I tried using the function DATESBETWEEN to count the total between a specified date range, but I am getting an error message that reads: 

eli_n_2-1672776204809.png

 

Any ideas on how to resolve?

Thank you!

 

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1672796333099.png

(2)We can create a table.

Calendar = CALENDAR(DATE(2015,01,01),DATE(2019,06,30))

(3) We can create a measure. 

Pre-Intervention Incident Count =
SUMX (
    SUMMARIZE (
        'ReportTable',
        'ReportTable'[report_no],
        "_1",
            COUNTX (
                FILTER (
                    'ReportTable',
                    'ReportTable'[date] >= MIN ( 'Calendar'[Date] )
                        && 'ReportTable'[date] <= MAX ( 'Calendar'[Date] )
                ),
                'ReportTable'[report_no]
            )
    ),
    [_1]
)

(4) Then the result is as follows.

vtangjiemsft_1-1672796421808.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Anonymous
Not applicable

Hi Neeko,

 

Thank you for your response! That seemed to work, however I have two different date ranges I have to account for:

1/1/2015 - 6/30/2019

7/1/2019 - Present

 

How can I account for both date ranges with a single calendar table? The solution you provided would account for a single date range at a time. 

 

Thank you!

Anonymous
Not applicable

Hi @Anonymous ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_1-1672882282238.png

(2) We can create two measures. 

Pre-Intervention Incident Count (1/1/2015 - 6/30/2019) =
SUMX (
    SUMMARIZE (
        'ReportTable',
        'ReportTable'[report_no],
        "_1",
            COUNTX (
                FILTER (
                    'ReportTable',
                    'ReportTable'[date] >= DATE ( 2015, 1, 1 )
                        && 'ReportTable'[date] <= DATE ( 2019, 6, 30 )
                ),
                'ReportTable'[report_no]
            )
    ),
    [_1]
)
Pre-Intervention Incident Count (7/1/2019 - Present) =
SUMX (
    SUMMARIZE (
        'ReportTable',
        'ReportTable'[report_no],
        "_1",
            COUNTX (
                FILTER (
                    'ReportTable',
                    'ReportTable'[date] >= DATE ( 2019, 7, 1 )
                        && 'ReportTable'[date] <= TODAY ()
                ),
                'ReportTable'[report_no]
            )
    ),
    [_1]
)

(3) Then the result is as follows.

vtangjiemsft_2-1672882400706.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Anonymous
Not applicable

Circling back to my original post; I created a date table to address the duplicate dates issue, however it still doesn't seem to be working:

 

eli_n_0-1672786992194.png

I am not sure what the issue maybe 😕 

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