Forum Discussion
TaroGulati
1 year agoHelper III
Cross date time calculation
Hi all, I am stuck with the following scenario: I need to calculate time difference between (from table 1 minimum start date with category = B & type = X) and (from table 2 minimum date w...
- Anonymous1 year ago
Hi TaroGulati ,
Please try:
# Measure = VAR __start_datetime = CALCULATE ( MIN ( 'Table1'[START] ), 'Table1'[Category] = "B" && 'Table1'[Type] = "X" ) VAR __end_datetime = CALCULATE ( MIN ( 'Table2'[Date] ), 'Table2'[Category] = "C" ) RETURN SUMX( FILTER( ADDCOLUMNS ( FILTER ( 'Table1', 'Table1'[Category] = "A" && 'Table1'[Type] = "X" ), "@start_datetime", __start_datetime, "@end_datetime", __end_datetime ), 'Table1'[END]>=[@start_datetime] && 'Table1'[START]<=[@end_datetime] ), VAR __overlap_start = MAX('Table1'[START],[@start_datetime]) VAR __overlap_end = MIN('Table1'[END],[@end_datetime]) RETURN DATEDIFF(__overlap_start,__overlap_end,HOUR) )Best Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
TaroGulati
1 year agoHelper III
hi, sorry didn't understand your answer.
- lbendlin1 year agoSuper User
Please provide better sample data.