Forum Discussion
Service recall rate measure
- 5 years ago
Hi jhowe1 ,
I think a lot of the problem stems from the way the data is related, to me the booking is the fact, given the relationships, so I added the asset and closed on keys to the booking table, then created a calc column that identifies if the booking is a recall
Recall Rate Flag = VAR _closed_on = Booking[Closed_on] VAR _closed_minus_7 = DATE(YEAR(Booking[Closed_on]), MONTH ( Booking[Closed_on] ), DAY (Booking[Closed_on])) - 7 VAR _customer = ( Booking[KEY_Customer] ) VAR _asset = ( Booking[KEY_Asset] ) VAR _engineer = ( Booking[KEY_Engineer] ) VAR _booking = ( Booking[KEY_WorkOrder] ) RETURN if(CALCULATE ( COUNTROWS ( Booking ), FILTER( ALL( Booking ), _asset <> -1 && Booking[Closed_On] < _closed_on && Booking[Closed_On] >= _closed_minus_7 && Booking[KEY_Asset] = _asset && Booking[KEY_Customer] = _customer && Booking[KEY_Engineer] = _engineer ) )>0, 1)Then created a measure that counts the bookings that are recalls
Recall Rate New = sum('Booking'[Recall Rate Flag])which results in the image below, you may need to scrub the data a little on the way in to ensure that you have a one to one on the workorder and booking.
I can attach the file here or send to you through private message, your choice.
Thanks
Can I get some assistance with this please, it will start to become urgent thanks.
Hi jhowe1,
Please have a look at the following Measure, very similar to the answer from v-lionel-msft but accounts for the 7 day window, please note that the measure will get evaluated in context of the data being displayed in the visual and the filters applied and will only count the recalls in the window represented by the contect. and the prior 7 days, so if an item is fixed once every 8 days it will not be counted as a recall.
Hope that makes sense
Recall Rate =
var _closed_on = SELECTEDVALUE('Table'[ClosedOn])
var _closed_minus_7 = DATE(YEAR(SELECTEDVALUE('Table'[ClosedOn])), MONTH(SELECTEDVALUE('Table'[ClosedOn])), DAY(SELECTEDVALUE('Table'[ClosedOn]))) - 7
var _customer = SELECTEDVALUE('Table'[Customer])
var _asset = SELECTEDVALUE('Table'[Asset])
return
CALCULATE(
COUNTROWS('Table'),
FILTER(
ALL('Table'),
('Table'[ClosedOn]<_closed_on && 'Table'[ClosedOn] >=_closed_minus_7) &&
'Table'[Asset] = _asset &&
'Table'[Customer] = _customer
)
)
results in the following table, in order to display the null you will need to tell the visual to display blank values
Hope that helps
- jhowe15 years ago
Helper III
Hi richbenmintz I think we're getting close however i'm not getting any results from this measure
What am I missing? Also i want this count to be able to be split by engineer (see sql code) which is in a different table 'dbo.FactBooking'
- richbenmintz5 years ago
Resident Rockstar
Hi jhowe1
Are you able to provide a sample pbix file, would make things much easier for me and other members of the community to provide the correct answer.
Thanks,
- jhowe15 years ago
Helper III
Hi Rich,
Just realised you're using selected measure and I only had engineer name and recall rate selected. I replicated your table visual (results incorrect anyway, there's dates in here that aren't even in my factworkorder table). Some of the data in this dataset maybe sensitive, I would prefer a quick teams call if possible, if the pasted is not enough?
and pasted my DAX below
Recall Rate = var _closed_on = SELECTEDVALUE(WorkOrder[Closed On]) var _closed_minus_7 = DATE(YEAR(SELECTEDVALUE(WorkOrder[Closed On])), MONTH(SELECTEDVALUE(WorkOrder[Closed On])), DAY(SELECTEDVALUE(WorkOrder[Closed On]))) - 7 var _customer = SELECTEDVALUE(WorkOrder[KEY_Customer]) var _asset = SELECTEDVALUE(WorkOrder[KEY_Asset]) return CALCULATE( COUNTROWS(WorkOrder) ,FILTER( ALL(WorkOrder), (WorkOrder[Closed On] <_closed_on && WorkOrder[Closed On] >=_closed_minus_7) && WorkOrder[KEY_Asset] = _asset && WorkOrder[KEY_Customer] = _customer ) )SQL
SELECT FB.KEY_Engineer, FWO.KEY_Customer, FWO.KEY_Asset, FWO.ClosedOn FROM pbi.FactWorkOrder AS FWO JOIN pbi.FactBooking AS FB ON FB.KEY_WorkOrder = FWO.KEY_WorkOrder WHERE FWO.WorkOrderType = 'Breakdown' AND KEY_Asset IS NOT NULL AND ClosedOn IS NOT NULL ORDER BY ClosedOn DESCData
KEY_Engineer KEY_Customer KEY_Asset ClosedOn613 540527 -1 2021-02-10 16:59:23797 540527 248 2021-02-10 16:24:35797 540527 -1 2021-02-10 16:24:17797 540527 23537 2021-02-10 16:24:01797 540527 248 2021-02-10 16:23:14800 540527 248 2021-02-10 16:02:48797 540527 248 2021-02-10 11:55:16477 540527 248 2021-02-10 11:13:07428 530041 2053 2021-01-29 09:29:41428 530041 6676 2021-01-28 10:29:05797 530041 6676 2021-01-26 11:06:03797 530041 6676 2021-01-26 10:52:17797 530041 6676 2021-01-25 17:54:00797 540527 5256 2021-01-25 16:41:19797 540527 5256 2021-01-25 15:15:50428 533252 5592 2021-01-25 14:45:46797 540527 14966 2021-01-25 14:38:41428 540527 5256 2021-01-25 12:21:53797 540527 14966 2021-01-20 16:11:23797 530041 19987 2021-01-18 11:36:46797 530041 19987 2021-01-15 12:07:40428 530041 24564 2021-01-14 10:40:38428 530041 19987 2021-01-13 12:13:32428 540527 5256 2021-01-13 11:56:52428 530041 19987 2021-01-13 11:38:52428 530041 19987 2021-01-13 11:10:11797 530041 19987 2021-01-13 10:21:15797 540527 5256 2021-01-12 14:43:50428 540527 5256 2021-01-12 13:49:04797 530041 19987 2021-01-11 12:30:45428 530041 19987 2021-01-11 11:13:42797 530041 19987 2021-01-11 11:12:56797 530041 19987 2021-01-08 16:48:18797 530041 19987 2021-01-08 16:41:46795 541084 12826 2021-01-08 08:21:34795 533979 5135 2021-01-06 14:59:43795 533252 10821 2021-01-06 11:49:06795 540527 5256 2021-01-06 11:34:45795 530041 24564 2021-01-06 11:19:50428 530041 19987 2021-01-04 11:40:28428 530041 19987 2021-01-04 11:26:13428 530041 19987 2020-12-17 10:12:26428 530041 19987 2020-12-17 10:12:26428 530041 19987 2020-12-16 12:07:14428 530041 19987 2020-12-15 16:39:01428 530041 19987 2020-12-15 15:50:49428 530041 19987 2020-12-15 13:07:31797 530041 19987 2020-12-10 15:34:48428 530041 19987 2020-12-04 10:29:21800 530041 19987 2020-11-30 16:30:48800 530041 19987 2020-11-30 16:30:48800 530041 -1 2020-11-30 16:16:02800 530041 -1 2020-11-30 16:16:02795 530041 19987 2020-11-24 16:17:20795 530041 19987 2020-11-24 14:42:19795 530041 19987 2020-11-16 15:48:30795 529402 14956 2020-11-16 15:30:34795 529402 14956 2020-11-16 15:30:34795 529402 14956 2020-11-16 15:30:34795 530041 19987 2020-11-12 10:36:12795 530041 19987 2020-11-12 10:36:12797 530041 19987 2020-11-11 17:07:12The extra dates in the table visual are coming from work orders that don't have a booking, where as i'm only interested in work orders that have a booking for this calculation.