Forum Discussion

brettg's avatar
brettg
Icon for Helper II rankHelper II
8 years ago
Solved

Max Date per Distinct User which updates with date slider

Hi All,

 

I haven't come across a post which deals with this issue yet, so I thought I would share. 

 

I would like to get a Max date for each Distinct User, and this Max date will update based on a date slider I use.

 

This calculated column for example;

 

CALCULATE(MAX('Table'[TestDate]),FILTER('Table', 'Table'[User]=EARLIER('Table'[User])))

 

This will bring back the users latest test in the table as a whole, but if i change the date slider I want this latest test to update within that date range. 

 

Is this possible?

 

  • it does return the date per user, at least with my data

8 Replies

  • Stachu's avatar
    Stachu
    Icon for Community Champion rankCommunity Champion

    calculated column will not change based on slicer, you will need a measure for that
    for a measure this simple syntax should work

    Measure = LASTDATE('Table'[Test Date])

    if you don't won't to see dates in the total row then use this

    Measure no totals = 
    VAR User = SELECTEDVALUE('Table'[User])
    RETURN
    CALCULATE(LASTDATE('Table'[Test Date]),'Table'[User]=User
    • brettg's avatar
      brettg
      Icon for Helper II rankHelper II

      Thanks for your response!

       

      I'm using the second measure you sent across, but it seems to only provide the latest date per row instead of distinct user?

       

      Also, I think I need to use Max('Table' [Test Date]) to capture the latest time of the test as well?

       

       

      • Stachu's avatar
        Stachu
        Icon for Community Champion rankCommunity Champion

        if you see evaluation by row then I assume you added this syntax as a column rather than measure, and then it won't work properly.

        try adding this code as a measure, then you should only be able to see it in visual & field list, not as a column in the underlying table

        EDIT - as for the LASTDATE vs MAX, both should do the job, but indeed MAX may be better choice as it doesn't do context transition