Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I am working on a dataset having accidents data for 5 Years,
I want to retrieve the last time an accident happened, which was 1 accident and it was March 2016, then i will calculate the days since that date. I want to show it on a Card
Date of Last Accident | March 2016 |
Days since last Accidents | 2,344 |
I am not sure how the measure formula would be
Appreciate your assistance or advice
Solved! Go to Solution.
Hi @Oelshamy ,
Please try this measure.
Measure =
VAR _lastdate = MAX('HSE'[Date])
VAR _month = FORMAT(_lastdate,"MMMM YYYY")
VAR _days = DATEDIFF(_lastdate,TODAY(),DAY)
VAR _result = "Date of Last Accident " & _month & UNICHAR(10) & "Days since last Accidents " & _days & " days."
RETURN
_result
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data
Hi @Oelshamy ,
Please try this measure.
Measure =
VAR _lastdate = MAX('HSE'[Date])
VAR _month = FORMAT(_lastdate,"MMMM YYYY")
VAR _days = DATEDIFF(_lastdate,TODAY(),DAY)
VAR _result = "Date of Last Accident " & _month & UNICHAR(10) & "Days since last Accidents " & _days & " days."
RETURN
_result
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data
Thank you very much ... worked perfectly as required
Appreciate it
Hi @ValtteriN ,
I am not getting the same values when applying the values:
Thank you for your response, @ValtteriN
What about getting the correspondent value that shows March 2016 as last time the accident happened,
I am trying the below formula
Hi,
For getting the date/month you can modify the dax just a bit:
Date = CALCULATE(DATEDIFF(MAX('Table (7)'[Last accident]),ALL('Table (7)'[Last accident]))
Month = CALCULATE(MONTH(MAX('Table (7)'[Last accident])),ALL('Table (7)'[Last accident]))
This will simply get the maximum value when the last accident happened.
Proud to be a Super User!
Hi,
Here is one way to do this:
I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!
My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/
Proud to be a Super User!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
9 | |
8 | |
8 |
User | Count |
---|---|
14 | |
12 | |
11 | |
11 | |
8 |