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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
MLH4
Frequent Visitor

Days Between - Days Since DAX

I have been trying to show days between injury dates. I was able to accomplish this task. However, the most recent "Days Between" data point will never be accurate since another injury has yet to occur. 

 

I have also created a "Days Since" measure to show how many days since the last injury. 

 

My question is, how can I have a measure show days between injury unless it is the most recent injury(unable to show days between). So, I am needing a days between previous injuries along with a days since count for the most recent datapoint. 

 

Below are the current dax formulas for each measure:

 

DaysBetweenSteps = VAR IndexNum = Max(Safety[Index]) VAR PreviousIndexNum = CALCULATE(MAX(Safety[Index]), FILTER(ALLSELECTED(Safety), Safety[Index] < IndexNum)) VAR CurrentDate = VALUE(SELECTEDVALUE(Safety[ACTUALINCIDENTDATE])) VAR PriorDate = VALUE(CALCULATE(SELECTEDVALUE(Safety[ACTUALINCIDENTDATE]), FILTER(ALL(Safety), Safety[Index] = PreviousIndexNum)))  RETURN  IF(IndexNum= CALCULATE(MIN(Safety[Index]), ALLSELECTED(Safety)), 0, CurrentDate - PriorDate)
 
 
Days Since = if(LASTDATE(Safety[Date])=blank(),blank(),(1.*(today() - LASTDATE(Safety[Date])-1)))
 
 
The image below shows the current chart along with the desired outcome(In red):MLH4_0-1702488255849.png

 

 
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

However, the most recent "Days Between" data point will never be accurate since another injury has yet to occur. 

 

Read about COALESCE  and TODAY()

View solution in original post

3 REPLIES 3
lbendlin
Super User
Super User

However, the most recent "Days Between" data point will never be accurate since another injury has yet to occur. 

 

Read about COALESCE  and TODAY()

MLH4
Frequent Visitor

Thank you for your response! This did work. However, when I change the filters to show other category of injuries, the chart is not accurate at all. It seems the chart is only accuracte with one type of injury. 

MLH4_0-1702911472966.png

MLH4_1-1702911540183.png

Would you have any idea to why this is? Everything is exactly the same other than the injury category filter. 

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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