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.
I am trying to generate the last date of use when time used > 0, for a list of assets within a direct query. The data is structured as follows:
I would like to generate different measures to create the following tables:
The primary measure I need to solve for is 'Last date used'. My current measure yields this result:
Last Date Used =
VAR FirstVisibleOrder =
MIN ( 'Pump Gear Usage'[Last Stage ID])
VAR PreviousOrder =
CALCULATE (
MAX ( 'Pump Gear Usage'[Last Stage ID]),
REMOVEFILTERS ( Dates[Date] ),
'Pump Gear Usage'[Last Stage ID] < FirstVisibleOrder,
'Pump Gear Usage'[Time In Gear] <>0
)
VAR FilterPreviousOrder =
TREATAS (
{
PreviousOrder
},
'Pump Gear Usage'[Last Stage ID]
)
VAR Result =
CALCULATE (
MAX('Pump Gear Usage'[End time]),
REMOVEFILTERS ( Dates[Date]),
FilterPreviousOrder
)
RETURN
Result
Solved! Go to Solution.
@lbendlin thanks for leading me to the solution. This dax ended up working:
LDU =
var d = SELECTEDVALUE('Pump Gear Usage'[Pump_Name])
var d2 = CALCULATE(LASTDATE('Pump Gear Usage'[End time]),'Pump Gear Usage'[Pump_Name]=d,'Pump Gear Usage'[Pump Hours]<>0)
VAR LDU = CALCULATE(MAX('Pump Gear Usage'[End time]),FILTER('Pump Gear Usage','Pump Gear Usage'[End time]<d2 && 'Pump Gear Usage'[Pump_Name]=d))
RETURN
LDU
@lbendlin thanks for leading me to the solution. This dax ended up working:
LDU =
var d = SELECTEDVALUE('Pump Gear Usage'[Pump_Name])
var d2 = CALCULATE(LASTDATE('Pump Gear Usage'[End time]),'Pump Gear Usage'[Pump_Name]=d,'Pump Gear Usage'[Pump Hours]<>0)
VAR LDU = CALCULATE(MAX('Pump Gear Usage'[End time]),FILTER('Pump Gear Usage','Pump Gear Usage'[End time]<d2 && 'Pump Gear Usage'[Pump_Name]=d))
RETURN
LDU
I would define "Last Date Used" thusly:
Please provide sample data in usable format (not as a picture).
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
97 | |
84 | |
67 | |
60 |
User | Count |
---|---|
150 | |
120 | |
99 | |
87 | |
68 |