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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Days Between Dates Issue

Hello,

 

I am attempting to calculate the days between two dates (using a calculated column), which is easy! However, I am returning incorrect values. See below screenshot:

jfeddes_0-1650899908872.png

For the selected "2022-02", I am being returned 31 days. I would like to return days passed in January, as well as the month selected. Not just January. So, this should return 31 + 28 = 59 days for January + February.

 

Any tips/tricks on adjusting my formula to accomodate?

 

Thanks,

 

Joel

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can solve your problem with measure, mainly because you need to calculate the second date.

Maesure:

Days between date =
DATEDIFF (
    DATE ( YEAR ( TODAY () ), 1, 1 ),
    DATE ( YEAR ( TODAY () ), SELECTEDVALUE ( 'Date'[Date].[MonthNo] ) + 1, 1 ) - 1,
    DAY
)

vzhangti_0-1651127114115.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

4 REPLIES 4
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can solve your problem with measure, mainly because you need to calculate the second date.

Maesure:

Days between date =
DATEDIFF (
    DATE ( YEAR ( TODAY () ), 1, 1 ),
    DATE ( YEAR ( TODAY () ), SELECTEDVALUE ( 'Date'[Date].[MonthNo] ) + 1, 1 ) - 1,
    DAY
)

vzhangti_0-1651127114115.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

Anonymous
Not applicable

Yup! That'll work. Thanks much.

Greg_Deckler
Community Champion
Community Champion

@Anonymous For the first parameter, use DATE(2022,1,1). Also you can get the number of days between 2 dates using simple subtraction:

 

([date1] - [date2]) * 1.



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

Hey Greg,

 

Thanks for the tips, but that doesn't quite solve my current predicament. See below screenshot:

jfeddes_0-1650903851758.png

When I select 2022-02 on my slicer, I want to see days passed between January 1 and Februrary 28th (59 days total). Currently, when I select 2022-02, I only get January's days (31). I want January + February (59 days).

 

Thanks,

 

Joel

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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