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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.