Forum Discussion

patri0t82's avatar
patri0t82
Icon for Post Patron rankPost Patron
3 years ago
Solved

Measure for MAX Date, for Every Record

Hello, I have two columns.   Schedule[Date] and Schedule[Job], I'm trying to create a measure that finds the MAX [Date] for every record in [Job]. Some of the formulas I've tried (and no longer re...
  • PaulDBrown's avatar
    PaulDBrown
    3 years ago

    patri0t82 

    My apologies. I misunderstood what you were after (I though you only wanted one name based on the last modified date). See if this measure returns what you expect (even in Direct Query?)

    Latest Job by date =
    VAR _MaxDateTime =
        CALCULATE (
            MAX ( 'Main Table'[ModifiedDate] ),
            FILTER (
                ALLSELECTED ( 'Main Table' ),
                'Main Table'[Name] = MAX ( 'Main Table'[Name] )
            )
        )
    RETURN
        CALCULATE (
            MAX ( 'Main Table'[Job] ),
            FILTER ( 'Main Table', 'Main Table'[ModifiedDate] = _MaxDateTime )
        )
    

     

  • PaulDBrown's avatar
    PaulDBrown
    3 years ago

    patri0t82 

    Thinkg about it, I don't think my last suggestion delivers what you need, since it shows the last job by name, but ignores that las modified date. 

    So see if this measure returns the job by last modified date:

    Latest job by modified date =
    VAR _MaxDateTime =
        CALCULATE (
            MAX ( 'Main Table'[ModifiedDate] ),
            FILTER (
                ALLSELECTED ( 'Main Table' ),
                'Main Table'[Job] = MAX ( 'Main Table'[job] )
            )
        )
    RETURN
        CALCULATE (
            MAX ( 'Main Table'[Job] ),
            FILTER ( 'Main Table', 'Main Table'[ModifiedDate] = _MaxDateTime )
        )