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

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
kentyler New Contributor
New Contributor

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]))
Highlighted
saanah2019 Member
Member

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 Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)