The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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 |
---|---|
16 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
8 | |
8 |