Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Arkhos94
Helper IV
Helper IV

Filters/slicer on only some of the data of a measure

I have a basic table about car repair :

   Car ID     RepairPerformedRepairDate
11Nov. 8th
21Oct. 21st
30 
41Nov. 24th
51Dec. 1st

(real table is a bit more complex than that with 100k repairs and one more column with the ID of the repair performed) 

 

Car ID is a unique vehicle ID

RepairPerformed is 0 if the repair is not performed to date, 1 if it is 

RepairDate is nothing if the repair is not performed to date, the repair date if it is 

 

First step, I want the % of repair performed

Easy : create a custom measure : %repair = sum(RepairPerformed) / count (Car ID)

 

Now I want to be able to go back in time

Today, 80% cars are repaired

But at November 30th it was 60% (3 out of 5)

At November 15th it was 40% (2 out of 5)

 

I tried to use a slicer on repair date, but it does not work.

If I slice repair date from 01st January to November 15th, % repair become 75% (car n° 4 is removed from the data, so 3 cars out of 4 repaired => 75%)

 

I don't have a clue on how to get to the real result. 

1 ACCEPTED SOLUTION
d_gosbell
Super User
Super User

So the issue is that the date slicer is also filtering the count of cars. So you could do something like the following:

 

%repair = sum([RepairPerformed]) / CALCULATE( count ( [Car ID]), ALL( Repairs[RepairDate]) )

 

But I can still see some issues. This assumes a car only has one repair and to truely go "back in time" you would need to know when the car was booked in for repair so you did not count cars for historic dates that had not yet come in for repair.

View solution in original post

3 REPLIES 3
Arkhos94
Helper IV
Helper IV

Thanks for the help, I will try this ASAP

 

The "real" database is build with one line for each repair/car with a repair ID unique for each repair/vehicle (the same ID can be used for multiple car but will be used only once per vehicle). 

 

I will add a column with car ID and repair AD concatenated together so I have a unique repar/car ID. Then  I will use this ID for counting in the formula you gave me. 

 

Regarding booking issue : as long as a car is only booked RepairPerformed is 0 and RepairDate is empty. So they are easy to detect

 

Edit : solution tested and it work great, thanks

d_gosbell
Super User
Super User

So the issue is that the date slicer is also filtering the count of cars. So you could do something like the following:

 

%repair = sum([RepairPerformed]) / CALCULATE( count ( [Car ID]), ALL( Repairs[RepairDate]) )

 

But I can still see some issues. This assumes a car only has one repair and to truely go "back in time" you would need to know when the car was booked in for repair so you did not count cars for historic dates that had not yet come in for repair.

Arkhos94
Helper IV
Helper IV

Does someone have an hint on how to solve my problem ? I'm still stuck

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.