Forum Discussion
COnditonal Column
- 3 years ago
Please try
MeasureDifference =
VAR FirstSelectedDate =
CALCULATE (
MIN ( 'PM On Time Performance Bus PM-BI-002 (2)'[Completion Date.Completion Date Level 01] ),
ALLSELECTED (),
VALUES ( 'PM On Time Performance Bus PM-BI-002 (2)'[Equipment.Equipment Level 01.Key] )
)
RETURN
SUMX (
'PM On Time Performance Bus PM-BI-002 (2)',
IF (
'PM On Time Performance Bus PM-BI-002 (2)'[Completion Date.Completion Date Level 01] = FirstSelectedDate,
0,
'PM On Time Performance Bus PM-BI-002 (2)'[Variable Difference]
)
)
tamerj1 thank you, but not quite what I was looking for.
For example, for Equipment key 1104, it should just "Else=0" because there is no previous equipment key record for that equipment. In Equipment 1106 it should calculate the "current - previous" mileage because there is a previous entry.
What it should look like:
amandabus21
Perhaps I misunderstood your requirement. I'm still not sure if I fully understand 🙂
Please try
Variable Difference =
VAR CurrentDate = 'PM On Time Performance Bus PM-BI-002 (2)'[Completion Date.Completion Date Level 01]
VAR Curr = 'PM On Time Performance Bus PM-BI-002 (2)'[Mileage]
VAR CurrentEquipmentTable =
CALCULATETABLE (
'PM On Time Performance Bus PM-BI-002 (2)',
ALLEXCEPT (
'PM On Time Performance Bus PM-BI-002 (2)',
'PM On Time Performance Bus PM-BI-002 (2)'[Equipment.Equipment Level 01.Key]
)
)
VAR TableBefore =
FILTER (
CurrentEquipmentTable,
'PM On Time Performance Bus PM-BI-002 (2)'[Completion Date.Completion Date Level 01] < CurrentDate
)
VAR PreviousRecord =
TOPN (
1,
TableBefore,
'PM On Time Performance Bus PM-BI-002 (2)'[Completion Date.Completion Date Level 01]
)
VAR Prev =
MAXX ( PreviousRecord, 'PM On Time Performance Bus PM-BI-002 (2)'[Mileage] )
RETURN
Curr - COALESCE ( Prev, Curr )- amandabus213 years agoHelper V
tamerj1 yes this is almost exactly what I need! the formula is working great, just need to add the contional rule on top of it.
so, if there is there is no previous matyching equipment ID the Variable Difference formula should equal 0.
if there is a previous equipment ID, the formula needs to run.
In this example, the equipment key = 1104, variable difference should yield a "0" because there is no other previous record of 1104.
But the second record of1105 is correct, because there is a previous record.
- tamerj13 years agoCommunity Champion
Strange! It should return 0. Actually this is the purpose of the COALESCE. Would you please share the code that you have used?
- amandabus213 years agoHelper V
tamerj1 I used the one you provided above.
Only other thing I could maybe think of is a Date Slicer added using, "Completion Date.Completion Date Level 01"