Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Filter data by dates closest to today

Hello,    I'd like to find the closest date to today in order to "tag" a product with its respective label. For example, I have a table of dates, set up like so:   Product            Date        ...
  • Anonymous's avatar
    Anonymous
    7 years ago

    Hi Anonymous ,

     

    Try this DAX Column:

    Closest Date = VAR LatestDate= CALCULATE(
        MAX('Table (3)'[Date]),
    
        FILTER('Table (3)','Table (3)'[Date] < TODAY() &&
        'Table (3)'[Product] = earlier('Table (3)'[Product])),'Table (3)'[Date])
    return
    if('Table (3)'[Date]=LatestDate,1,0)

    Put the Dax column in the visual level filter and filter for 1.

     

    My output:

     

     

    Let me know if this works for you.

     

    Thanks,

    Tejaswi