Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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, @JoaoSifredo
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, @JoaoSifredo
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, @JoaoSifredo
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)
)
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
22 | |
7 | |
6 | |
6 | |
6 |
User | Count |
---|---|
27 | |
12 | |
10 | |
9 | |
6 |