Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hello community, I need help with a health safety dashboard at work.
I can't calculate accident-free days.
I have a table of accident records, you can see it below:
I want to calculate the accumulated number of days without accidents if it is an "AT" accident.
| Data | Tipo de Evento |
| 06/01/2023 | AT |
| 11/01/2023 | AT |
| 15/01/2023 | AT |
| 09/01/2023 | PS |
| 26/01/2023 | PS |
| 27/01/2023 | PS |
| 27/01/2023 | PS |
| 31/01/2023 | PS |
| 05/01/2023 | QA |
| 16/01/2023 | QA |
| 25/01/2023 | PS |
| 17/01/2023 | QA |
| 16/01/2023 | QA |
| 24/01/2023 | QA |
Solved! Go to Solution.
hi, @Anonymous
try below measure
Measure 2 =
var a = CALCULATE(MIN('Table (2)'[Data]),FILTER(ALL('Table (2)'),'Table (2)'[Tipo de Evento]="at"))
RETURN
SUMX(
FILTER(
'Table (2)',
[Tipo de Evento]="at" &&
[Data]<=MAX([Data])
),
DATEDIFF(a,MIN('Table (2)'[Data]),DAY)
)
Hi @Dangar332
Thank you very much for your solution, however I found a solution, which is not perfect. It is not calculating before the first event. How can you see.
hi, @Anonymous
in your var data _anteior_acidente you count previous data of Tipo de Evento="AT" of current date of "at"
means currentdate :15/01/2023 and var data _anteior_acidente is calculate its previous value of "at" that is 11/1/2023
update var data _anteior_acidente =
calculate(
min(tablename[data]),
tablename[data]<=data_currente,
tablename[tipo de evento]="at"
)
you get your answer
hi, @Anonymous
try below measure
Measure 2 =
var a = CALCULATE(MIN('Table (2)'[Data]),FILTER(ALL('Table (2)'),'Table (2)'[Tipo de Evento]="at"))
RETURN
SUMX(
FILTER(
'Table (2)',
[Tipo de Evento]="at" &&
[Data]<=MAX([Data])
),
DATEDIFF(a,MIN('Table (2)'[Data]),DAY)
)
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 7 | |
| 6 | |
| 5 | |
| 5 |
| User | Count |
|---|---|
| 24 | |
| 11 | |
| 11 | |
| 9 | |
| 8 |