Forum Discussion
Calculating date difference across rows with a criteria
- 8 years ago
Hi samlittleTT,
To achieve your requirement, create a measure using DAX formula like this:
Diff = VAR gate1_start = CALCULATE(MIN('table'[Start Date]), 'table'[Gate Number]= "Gate1") VAR gate2_start = CALCULATE(MIN('table'[Start Date]), 'table'[Gate Number]= "Gate2") RETURN DATEDIFF(gate1_start, gate2_start, DAY)PBIX file here: https://www.dropbox.com/s/yxmkmq1w9bnwffp/Calculating%20date%20difference%20across%20rows%20with%20a%20criteria.pbix?dl=0
Regards,
Jimmy Tao
Hi samlittleTT,
To achieve your requirement, create a measure using DAX formula like this:
Diff =
VAR gate1_start = CALCULATE(MIN('table'[Start Date]), 'table'[Gate Number]= "Gate1")
VAR gate2_start = CALCULATE(MIN('table'[Start Date]), 'table'[Gate Number]= "Gate2")
RETURN
DATEDIFF(gate1_start, gate2_start, DAY)
PBIX file here: https://www.dropbox.com/s/yxmkmq1w9bnwffp/Calculating%20date%20difference%20across%20rows%20with%20a%20criteria.pbix?dl=0
Regards,
Jimmy Tao
- samlittleTT8 years agoNew Member
Hi Jimmy,
Am I right in thinking that to make this expand for more than just gates 1 and 2 I repeat the formula to run through gate 3 also like the below? I would then need to nest the date diff into a IF formula right?
Diff = VAR gate1_start = CALCULATE(MIN('table'[Start Date]), 'table'[Gate Number]= "Gate1") VAR gate2_start = CALCULATE(MIN('table'[Start Date]), 'table'[Gate Number]= "Gate2")
VAR gate3_start = CALCULATE(MIN('table'[Start Date]), 'table'[Gate Number]= "Gate3") RETURN DATEDIFF(gate1_start, gate2_start, DAY)- v-yuta-msft8 years agoCommunity Support
Hi samlittleTT,
Sure, you can add more variables if you need and nest them in IF formula. It's depend on your requirement.
Regards,
Jimmy Tao