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.
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.
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
11 | |
9 | |
6 |