Forum Discussion
amandabus21
3 years agoHelper V
Difference in Values
Hello, How can I get a differene from the last value? In this example I need the difference in mileage from the last entry. (24,695 - 18,923) (30,781 - 24,695) etc Example) Shou...
tamerj1
3 years agoCommunity Champion
Still not fixed. It is clear that the date values are still aligned left indicating that this is a text. Use the query editor (power query) to define the correct data of the column. However the first value will most probably remain wrong due to a gap in the code, other than that, other values shall be correct.
however we may also add additional dax to force correct order of the column
Measure =
SUMX (
SUMMARIZE (
'PM On Time Performance Bus PM-BI-002 (2)',
'PM On Time Performance Bus PM-BI-002 (2)'[Equipment Type.Equipment Type Level 01.Key],
'PM On Time Performance Bus PM-BI-002 (2)'[Completion Date.Completion Date Level 01],
'PM On Time Performance Bus PM-BI-002 (2)'[Mileage]
),
VAR CurrentMileage = 'PM On Time Performance Bus PM-BI-002 (2)'[Mileage]
VAR CurrentDate = DATEVALUE ('PM On Time Performance Bus PM-BI-002 (2)'[Completion Date.Completion Date Level 01])
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 Type.Equipment Type Level 01.Key]))
VAR TableBefore = FILTER (CurrentEquipmentTable, DATEVALUE ( 'PM On Time Performance Bus PM-BI-002 (2)'[Completion Date.Completion Date Level 01] ) < CurrentDate)
VAR PreviousRecord =
TOPN ( 1, TableBefore, DATEVALUE ( 'PM On Time Performance Bus PM-BI-002 (2)'[Completion Date.Completion Date Level 01] ))
VAR PreviousMileage =
MAXX ( PreviousRecord, 'PM On Time Performance Bus PM-BI-002 (2)'[Mileage] )
RETURN
IF ( NOT ISEMPTY ( PreviousRecord ), CurrentMileage -PreviousMileage )
)
amandabus21
3 years agoHelper V
- tamerj13 years agoCommunity Champion
- amandabus213 years agoHelper V
tamerj1 That isnt the date i was using, but I changed it anyways. Still getting the same wrong values.
- tamerj13 years agoCommunity Champion
Can you please share a sample file?