Forum Discussion

BigKev's avatar
BigKev
Helper III
5 years ago
Solved

Automatic select the latest date in the data

Hi All,

 

Does anyone know how I can set power bi to automatically select the latest date in my data?

Currently, this is my filter: 

 

When April Data becomes available, I want power BI to automatically select the April -21 value.

 

How can I achieve this without having to manually select the filter, and republish my report every month?

 

Cheers,

Kev

  • Hey BigKev ,

     

    yes, you should add a calculated column in your date table and check there if the row is the latest date.

    If yes, then give it a value like "Latest" otherwise not. 

     

    Then you can use that column as a slicer. As the report refreshes this column is also getting refreshed.

     

    If you need any help please let me know.
    If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
     
    Best regards
    Denis
     

2 Replies

  • selimovd's avatar
    selimovd
    Most Valuable Professional

    Hey BigKev ,

     

    yes, you should add a calculated column in your date table and check there if the row is the latest date.

    If yes, then give it a value like "Latest" otherwise not. 

     

    Then you can use that column as a slicer. As the report refreshes this column is also getting refreshed.

     

    If you need any help please let me know.
    If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
     
    Best regards
    Denis
     
  • v-robertq-msft's avatar
    v-robertq-msft
    Community Support

    Hi, @

    As far as I’m concerned, there’s no option to set the default value for slicer in Power BI at current, I think that the only way is to create a measure to filter the slicer to always display the latest date, you can try this:

    1. Create a calculated column in the date table:
    Datediff = DATEDIFF([Date],TODAY(),DAY)
    1. Create a measure:
    Is latest date =
    
    var _mindate=MINX(FILTER(ALL('Date'),[Date]<TODAY()),[Datediff])
    
    return
    
    IF(MAX('Date'[Datediff])=_mindate,1,0)
    1. Create a slicer and apply a filter to this slicer:

     

    And the slicer can always display the latest date.

    You can download my test pbix file here

     

    If this result is not what you want, you can go to the Power BI Idea to submit a new idea so that people with the same idea can vote for you. I will also vote for you.

     

    Best Regards,

    Community Support Team _Robert Qin

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.