cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
saanah2019 Regular Visitor
Regular Visitor

Get the Correct Value with respect to date and ID

I have a table with ID, date and Name

ex. 

101       3/12/2018     John

101       3/14/2018     John

101       3/16/2018     Adam

 

So THe issue is that I am trying to display information so that I see my First and Last values for each of these values. 

The issue is that when they are in a table, POwer BI shows me the last and first values in alphabetical order rather than corresponding to the value of their date. So ex. Adam will be under first and John under Last. How can I filter the row so that the name value looks at the date correctly to determine if it is the last or first?

 

This is what I get now:

Id           FirstDate    FirstName     LastDate   LastName

101      3/12/2018     Adam           3/16/2018     John

 

THe final result:

Id           FirstDate    FirstName     LastDate   LastName

101      3/12/2018     John            3/16/2018     Adam

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Get the Correct Value with respect to date and ID

@saanah2019 ,

 

You may just modify the measure above using dax like pattern below:

 

FirstName =
CALCULATE (
    MAX ( Table[Name] ),
    FILTER ( ALLEXCEPT ( Table, Table[ID] ), Table[Date] = MIN ( Table[Date] ) )
)

LastName =
CALCULATE (
    MAX ( Table[Name] ),
    FILTER ( ALLEXCEPT ( Table, Table[ID] ), Table[Date] = MAX ( Table[Date] ) )
)

Community Support Team _ Jimmy Tao

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

3 REPLIES 3
Highlighted
kentyler Established Member
Established Member

Re: Get the Correct Value with respect to date and ID

Try createing 2 measures

MaxDate = CALCULATE(MAX(Test[Date]),ALLEXCEPT(TEst,test[Name]))
and
MinDate = CALCULATE(MIN(Test[Date]), ALLEXCEPT(Test,Test[Name]))
saanah2019 Regular Visitor
Regular Visitor

Re: Get the Correct Value with respect to date and ID

Hey thanks for your effort. It didn't work. It just gave me the same date value for each row. 

I am essentially looking for :Find the last insurance name where date is max, find the last insurance name where date is min

 

@kentyler 

Community Support Team
Community Support Team

Re: Get the Correct Value with respect to date and ID

@saanah2019 ,

 

You may just modify the measure above using dax like pattern below:

 

FirstName =
CALCULATE (
    MAX ( Table[Name] ),
    FILTER ( ALLEXCEPT ( Table, Table[ID] ), Table[Date] = MIN ( Table[Date] ) )
)

LastName =
CALCULATE (
    MAX ( Table[Name] ),
    FILTER ( ALLEXCEPT ( Table, Table[ID] ), Table[Date] = MAX ( Table[Date] ) )
)

Community Support Team _ Jimmy Tao

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

Helpful resources

Announcements
New Kudos Received Badges Coming

New Kudos Received Badges Coming

Kudos to you if you earned one of these! Check your inbox for a notification.

Microsoft Implementation for Communities Wins Award

Microsoft Implementation for Communities Wins Award

Learn about the award-winning innovation that was implemented across Microsoft’s Business Applications Communities.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Kudoed Authors (Last 30 Days)
Users online (2,278)