cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GKJARC
Frequent Visitor

How to show the latest date within current selection in Power BI

Hi everyone,

 

In Power BI I'm trying to show the earliest date per ID. 

As an example, if the ValidFrom date slicer is set from 1-5-2020 to 1-12-2020, and a slicer for ID set to ID="1", the table visual should show only ID 1 with date 1-5-2020.

 

Sample data:

ID     ValidFrom 
1       1-1-2020

1       1-5-2020

2       1-1-2019

2       1-1-2019

3       1-1-2019

What would be a way to achieve this in Power BI?
Thanks!

1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi, @GKJARC 

 

According to your description, I think you can easily create a measure then use it in filter pane to filter the desired results.

Like this:

Measure =
VAR a =
    MINX (
        FILTER ( ALL ( 'Table' ), [ID] = SELECTEDVALUE ( 'Table'[ID] ) ),
        [ValidFrom ]
    )
RETURN
    IF (
        SELECTEDVALUE ( 'Table'[ValidFrom ] )
            IN DISTINCT ( 'Table 2'[Date] )
                && SELECTEDVALUE ( 'Table'[ValidFrom ] ) = a,
        1,
        0
    )

v-janeyg-msft_0-1620292061453.png

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

View solution in original post

4 REPLIES 4
v-janeyg-msft
Community Support
Community Support

Hi, @GKJARC 

 

According to your description, I think you can easily create a measure then use it in filter pane to filter the desired results.

Like this:

Measure =
VAR a =
    MINX (
        FILTER ( ALL ( 'Table' ), [ID] = SELECTEDVALUE ( 'Table'[ID] ) ),
        [ValidFrom ]
    )
RETURN
    IF (
        SELECTEDVALUE ( 'Table'[ValidFrom ] )
            IN DISTINCT ( 'Table 2'[Date] )
                && SELECTEDVALUE ( 'Table'[ValidFrom ] ) = a,
        1,
        0
    )

v-janeyg-msft_0-1620292061453.png

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

Jihwan_Kim
Super User
Super User

hi, @GKJARC 

Please check the below picture and the sample pbix file's link down below.

 

Picture4.png

 

Earliest Valid Date =
IF (
ISFILTERED ( IDs[ID] ),
CALCULATE (
MIN ( 'Table'[ValidFrom] ),
FILTER ( ALLSELECTED ( Dates ), Dates[Date] >= MIN ( Dates[Date] ) )
)
)

 

 

https://www.dropbox.com/s/5r5fidugk3q09wm/gkjarc.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


vanessafvg
Super User
Super User

what is the table structure and relationships? or is this one table?

 

earliestdate =
VAR selectedid =
    SELECTEDVALUE ( id )
RETURN
    CALCULATE ( MIN ( validfrom ), id = selectedid )





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




amitchandak
Super User
Super User

@GKJARC , Try a measure like

 

measure =
var _min = minx(allselected(Table), Table[ValidFrom])
return
calculate(min(Table[ID]), filter(Table, Table[ValidFrom] =_min))

 

 

Or plot this with ID column in visual

 

measure =
var _min = minx(allselected(Table), Table[ValidFrom])
return
calculate(count(Table[ID]), filter(Table, Table[ValidFrom] =_min))



New Power BI Features
Datamarts: https://youtu.be/8tskWsJTEpg
Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin !! Proud to be a Super User!
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
!! Subscribe to my youtube Channel !!

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors