The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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!
User | Count |
---|---|
15 | |
13 | |
8 | |
6 | |
6 |
User | Count |
---|---|
24 | |
19 | |
12 | |
9 | |
7 |