Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
saanah2019
Helper II
Helper II

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
v-yuta-msft
Community Support
Community Support

@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
v-yuta-msft
Community Support
Community Support

@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.

kentyler
Solution Sage
Solution Sage

Try createing 2 measures

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




Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


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 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.