Forum Discussion
Ecan20
5 years agoFrequent Visitor
DAX to compute the difference between date for specific items
Dear experts, I have a table like the example below with product ID, StartDate, EndDate. I would like to calculate the difference between the last EndDate and the first StartDate per each iem ID, li...
- 5 years ago
Please try this column expression and convert the column to type decimal.
NewColumn =
VAR thisID = IDs[ID]
VAR minDT =
MINX ( FILTER ( IDs, IDs[ID] = thisID ), IDs[StartDate] )
VAR maxDT =
MAXX ( FILTER ( IDs, IDs[ID] = thisID ), IDs[EndDate] )
RETURN
maxDT - minDTPat
Anonymous
5 years agoNot applicable
Are you sure you want a measure and not a calculated column? What should a measure return if there are many different ID's visible in the current context? Your picture suggests that you want a calculated column...
Ecan20
5 years agoFrequent Visitor
Anonymous you are right, a calculated column will work better for my case. I am not really familiar though, could you help me through the steps please? Thank you