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

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

Reply
EmmaLiuLiu
Helper I
Helper I

Count Number of Days between Two Days (Not Consecutive)

Hi, 

 

I have a data table with a column of different dates and I want to count the number of distinct days in there. I know I can create a column with Start Date and a column with End date then use DATEDIFF to calculate the number of days in between. However, the dates in the column are not consecutive. I've attached a sample column here. Can someone please help me? Thanks in advance!

Dates
1/1/2025
1/1/2025
1/3/2025
1/3/2025
1/3/2025
1/3/2025
1/4/2025
1/4/2025
1/10/2025

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thank for ryan_mayu and Irwan's concern about this issue.

 

Hi, @EmmaLiuLiu 

I'm not sure I understand your needs:
If you simply want to count the number of non-repeating dates in the date column, you can refer to the following Measure:

 

DistinctDaysCount = DISTINCTCOUNT('Table'[Dates])

 

 

vfenlingmsft_0-1736819509305.png

 


If you are trying to calculate the number of days between the next two dates in the Date column, you can refer to the following calculated column:

 

IntervalDays = 
VAR CurrentDate = 'Table'[Dates]
VAR PreviousDate = 
    CALCULATE(
        MAX('Table'[Dates]),
        FILTER(
            'Table',
            'Table'[Dates] < CurrentDate
        )
    )
RETURN
    IF(
        ISBLANK(PreviousDate),
        0,
        DATEDIFF(PreviousDate, CurrentDate, DAY) - 1
    )

 

 

vfenlingmsft_1-1736819585755.png

 

I have attached the pbix file for the above example below, hope it helps you.

 

If none of the above methods solved your problem, please share the details of the result you are expecting and we will try our best to solve the problem you are facing.

 

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Thank for ryan_mayu and Irwan's concern about this issue.

 

Hi, @EmmaLiuLiu 

I'm not sure I understand your needs:
If you simply want to count the number of non-repeating dates in the date column, you can refer to the following Measure:

 

DistinctDaysCount = DISTINCTCOUNT('Table'[Dates])

 

 

vfenlingmsft_0-1736819509305.png

 


If you are trying to calculate the number of days between the next two dates in the Date column, you can refer to the following calculated column:

 

IntervalDays = 
VAR CurrentDate = 'Table'[Dates]
VAR PreviousDate = 
    CALCULATE(
        MAX('Table'[Dates]),
        FILTER(
            'Table',
            'Table'[Dates] < CurrentDate
        )
    )
RETURN
    IF(
        ISBLANK(PreviousDate),
        0,
        DATEDIFF(PreviousDate, CurrentDate, DAY) - 1
    )

 

 

vfenlingmsft_1-1736819585755.png

 

I have attached the pbix file for the above example below, hope it helps you.

 

If none of the above methods solved your problem, please share the details of the result you are expecting and we will try our best to solve the problem you are facing.

 

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

ryan_mayu
Super User
Super User

@EmmaLiuLiu 

what's the expected output based on the sample data you provided?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Irwan
Super User
Super User

hello @EmmaLiuLiu 

 

i might be misunderstood but if the problem is non-consecutive day, is it possible to SUMMARIZE the table first?
something like this in new table.

Irwan_0-1736811735184.png

Hope this will help.

Thank you.

 

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.