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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sixtoquiles
Helper II
Helper II

Days between two days

HI, I have a slicer date, i create two measure column to calculate the max and min of the dates in the slicer.

 

Example: The slicer had: 2/1/2017 to 2/11/2017.

 

MinDate = MIN(Query1[EffectiveDate]) 

2/1/2017

MaxDate = MAX(Query1[EffectiveDate])

2/11/2017

 

I want make another measure column to calculate how many days are in between.

 

NumDayBetween = DATEDIFF([MinDate],[MaxDate],DAY)

Result: 8

 

And if a chosse 2/1/2017 to 2/1/2017. NumDayBetween = 0

 

Why?

Capture.JPG

 

1 ACCEPTED SOLUTION
Phil_Seamark
Employee
Employee

Hi @sixtoquiles

 

You say that "And if a chosse 2/1/2017 to 2/1/2017. NumDayBetween = 0"

 

To me they are the same day and so therefore the correct answer should be 0

 

I note in your image, you have different dates selected and that the MAX measure doesn't match the slicer selection.

 

I would recommend creating this on a DATE table where you are guaranteed to have 1 row per day with no gaps.  If your data table (in this case Query1) has no data on some days, you might see some odd things like this.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

1 REPLY 1
Phil_Seamark
Employee
Employee

Hi @sixtoquiles

 

You say that "And if a chosse 2/1/2017 to 2/1/2017. NumDayBetween = 0"

 

To me they are the same day and so therefore the correct answer should be 0

 

I note in your image, you have different dates selected and that the MAX measure doesn't match the slicer selection.

 

I would recommend creating this on a DATE table where you are guaranteed to have 1 row per day with no gaps.  If your data table (in this case Query1) has no data on some days, you might see some odd things like this.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.