Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi!
I need to create a measure to count when status is KO how many OKs are after the KO startdate.
Sample of data
Id | IdProduct | Status | Startdate |
1 | 3568 | KO | 1/8/23 9:00 |
2 | 3568 | OK | 1/8/23 10:00 |
3 | 3999 | KO | 1/8/23 10:30 |
4 | 3568 | OK | 1/8/23 12:00 |
What I need:
IdProduct | #postOK |
3568 | 2 |
3999 | 0 |
I tried:
Id | IdProduct | #postOK |
1 | 3568 | 2 |
2 | 3568 | 1 |
Any help will be appreciated.
Solved! Go to Solution.
Hi @elsacq ,
According to your description, here are my steps you can follow as a solution.
(1)My test data is the same as yours.
(2) We can create a measure.
PostOK =
var _date=CALCULATE(MAX('facttable'[Startdate]),FILTER(ALL('facttable'),'facttable'[IdProduct]=MAX('facttable'[IdProduct]) && 'facttable'[Status]="KO"))
var _count= COUNTROWS(FILTER(ALL('facttable'),'facttable'[IdProduct]=MAX('facttable'[IdProduct]) && 'facttable'[Startdate] > _date && 'facttable'[Status]="OK"))
return IF(_count = BLANK() ,0, _count)
(3) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
thanks a lot! I've been struggling with this for days
Hi @elsacq ,
According to your description, here are my steps you can follow as a solution.
(1)My test data is the same as yours.
(2) We can create a measure.
PostOK =
var _date=CALCULATE(MAX('facttable'[Startdate]),FILTER(ALL('facttable'),'facttable'[IdProduct]=MAX('facttable'[IdProduct]) && 'facttable'[Status]="KO"))
var _count= COUNTROWS(FILTER(ALL('facttable'),'facttable'[IdProduct]=MAX('facttable'[IdProduct]) && 'facttable'[Startdate] > _date && 'facttable'[Status]="OK"))
return IF(_count = BLANK() ,0, _count)
(3) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.