Forum Discussion
Count everytime a status change
- 8 years ago
Try this calculated column
EarliestIndex = VAR Temp = CALCULATE ( MAX ( [Index] ), FILTER ( Table1, [Index] < EARLIER ( [Index] ) && [STATUS] <> EARLIER ( [STATUS] ) ) ) VAR Temp1 = CALCULATE ( MIN ( [Index] ), FILTER ( Table1, [Index] > EARLIER ( [Index] ) && [STATUS] <> EARLIER ( [STATUS] ) ) ) RETURN IF ( [Index] > temp && OR ( [Index] < temp1, ISBLANK ( temp1 ) ), temp + 1, 0 )Then put the distinct count of this column along with the STATUS in a TABLE visual
This seems like an EARLIER problem. Sample source data that can be copied and pasted would help.
See my article on Mean Time Before Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586
Also...Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
| STATUS | Index |
| status1 | 1 |
| status1 | 2 |
| status1 | 3 |
| status1 | 4 |
| status2 | 5 |
| status2 | 6 |
| status1 | 7 |
| status1 | 8 |
| status1 | 9 |
| status1 | 10 |
| status2 | 11 |
| status2 | 12 |
| status2 | 13 |
| status1 | 14 |
Here's the sample data! I want something (a column or a measure, idk) that when I use it on the visuals, shows me that during that day, for example, I had 3 status 1 and 2 status 2, instead of 9 status 1 and 5 status 2, which would be just counting the number of times they appeared - which is exactly what I don't want it to do.
- Zubair_Muhammad8 years agoCommunity Champion
Try this calculated column
EarliestIndex = VAR Temp = CALCULATE ( MAX ( [Index] ), FILTER ( Table1, [Index] < EARLIER ( [Index] ) && [STATUS] <> EARLIER ( [STATUS] ) ) ) VAR Temp1 = CALCULATE ( MIN ( [Index] ), FILTER ( Table1, [Index] > EARLIER ( [Index] ) && [STATUS] <> EARLIER ( [STATUS] ) ) ) RETURN IF ( [Index] > temp && OR ( [Index] < temp1, ISBLANK ( temp1 ) ), temp + 1, 0 )Then put the distinct count of this column along with the STATUS in a TABLE visual
- Zubair_Muhammad8 years agoCommunity Champion
- stefanycheck8 years agoFrequent Visitor
It worked!!! Thanks a lot!