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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Syndicate_Admin
Administrator
Administrator

Get the number of days between two dates

Good afternoon

I am trying to get the number of days between two dates selected by two independent filters (Date 1 and Date 2), which take the values of two different tables:

Alberto99_0-1647347964226.png

What would be the corresponding function to calculate the number of days between the two dates?

Thank you very much, greetings.

2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Picture1.png

 

Days measure: =
ABS (
    INT ( SELECTEDVALUE ( Dates1[Dates1] ) - SELECTEDVALUE ( Dates2[Dates2] ) )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

Hi @Syndicate_Admin ,

 

Please try the DATEDIFF function:

Measure = DATEDIFF(MAX( Calendar1[Date1] ), MAX( Calendar2[Date2]), DAY )


Best Regards,
Liang
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
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Picture1.png

 

Days measure: =
ABS (
    INT ( SELECTEDVALUE ( Dates1[Dates1] ) - SELECTEDVALUE ( Dates2[Dates2] ) )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Good morning

I have tried to enter the formula that you put me and it only shows me a '0', if on both dates I put the same day, if it does not show me a 'blank'. I am working on the Power Bi version (January 2020) and my date format is the same for both filters and is as follows:

Alberto99_0-1647430899654.png

Thank you very much, greetings.

Hi @Syndicate_Admin ,

 

Please try the DATEDIFF function:

Measure = DATEDIFF(MAX( Calendar1[Date1] ), MAX( Calendar2[Date2]), DAY )


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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.