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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
brief001
Helper II
Helper II

Create grouped table from date field

I want to create a table from another table. This table must group the records whose unique record must be preserved based on a date field. In the table you see John in double, my result should be that John of team Sweden is kept, because that date has the highest value.

 

NameTeamDate
JohnTeam Polen01-01-2019
JohnTeam Sweden01-01-2021
FredTeam Holland01-01-2020
JackTeam Belgium01-01-2020
SteveTeam Germany01-01-2021

 

The DAX formula for creating a new calculated table must return the result below. (The John from Team Sweden must stay, because the date field of John from Team Poland was before the date of John from Team Sweden).

 

NameTeamDate
JohnTeam Sweden01-01-2021
FredTeam Holland01-01-2020
JackTeam Belgium01-01-2020
SteveTeam Germany01-01-2021

 

Thanks in advance for the help!

2 ACCEPTED SOLUTIONS
mahoneypat
Microsoft Employee
Microsoft Employee

Please use this table expression.

 

NewTable =
ADDCOLUMNS (
    DISTINCT ( Team[Name] ),
    "Date",
        CALCULATE (
            LASTNONBLANK (
                Team[Date],
                MIN ( Team[Date] )
            )
        ),
    "Team",
        CALCULATE (
            LASTNONBLANKVALUE (
                Team[Date],
                MIN ( Team[Team] )
            )
        )
)

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

wdx223_Daniel
Super User
Super User

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

View solution in original post

4 REPLIES 4
wdx223_Daniel
Super User
Super User

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

Thank you for also posting this answer. The formula works differently from the answer given earlier. But the result is the same. And I also understand this formula now that I read it.

mahoneypat
Microsoft Employee
Microsoft Employee

Please use this table expression.

 

NewTable =
ADDCOLUMNS (
    DISTINCT ( Team[Name] ),
    "Date",
        CALCULATE (
            LASTNONBLANK (
                Team[Date],
                MIN ( Team[Date] )
            )
        ),
    "Team",
        CALCULATE (
            LASTNONBLANKVALUE (
                Team[Date],
                MIN ( Team[Team] )
            )
        )
)

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thank you very much for your quick response. I've tested your formula and it works. And personally beautiful, I understand your formula too.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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