Forum Discussion

aggiebrown's avatar
aggiebrown
Icon for Helper III rankHelper III
3 years ago
Solved

Earliest / latest date calculation based on another column with datetime information / Date Diff

hi all,   I am stuck trying to create either a DAX Measure or Virtual DAX table which shows me Latest Date and Time of an Event, and based on that date and time, I want to look for any Calls or Ema...
  • Greg_Deckler's avatar
    3 years ago

    aggiebrown Try this. PBIX is attached below signature.

    Latest MQL Date Measure = MAXX( FILTER( 'fact_table', [total_mql_events] = 1 ), [event_datetime] )
    
    
    
    Latest Email Sent = 
        VAR __LatestEvent = [Latest MQL Date Measure]
        VAR __Table = ADDCOLUMNS( 'fact_table', "__contact_type", RELATED( 'dimmension_table'[contact_type] ) )
        VAR __Result = MAXX( FILTER( __Table, [__contact_type] = "EMAIL" && [event_datetime] > __LatestEvent), [event_datetime] )
    RETURN
        __Result
    
    
    
    Latest Call = 
        VAR __LatestEvent = [Latest MQL Date Measure]
        VAR __Table = ADDCOLUMNS( 'fact_table', "__contact_type", RELATED( 'dimmension_table'[contact_type] ) )
        VAR __Result = MAXX( FILTER( __Table, [__contact_type] = "CALL" && [event_datetime] > __LatestEvent), [event_datetime] )
    RETURN
        __Result