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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Przem
New Member

DAX GROUPBY and keep all columns

Greetings,
Using someones PowerBI dataset I want to group ORA IDs and keep the latest PROJECT ID for each ORA ID.
Data:

ORA IDPROJECT IDEND_DATE
11101.01.2023
11202.01.2023
21301.01.2023
21402.01.2023
21503.01.2023

Needed result:

ORA IDPROJECT IDEND_DATE
11202.01.2023
21503.01.2023

I need a table so I used:

 

ResultTable = GROUPBY('Data', 'Data'[ORA ID],
"Latest  Time", MAXX(CURRENTGROUP(),'DATA'[END_DATE]))

 

My result:

ORA IDEND_DATE
102.01.2023
203.01.2023

What should I do to keep all columns, or at least add PROJECT ID column?
Unfortunately I can't use GROUPBY in PowerQuery.

1 ACCEPTED SOLUTION
Dangar332
Super User
Super User

hi, @Przem 

try below

 

Table 2 = 
GROUPBY('Table (2)','Table (2)'[ORA ID],"project id",MAXX(CURRENTGROUP(),'Table (2)'[PROJECT ID]),"end date",MAXX(CURRENTGROUP(),'Table (2)'[END_DATE]))

 

or

 

Table 3 = 
var a = MAX('Table (2)'[END_DATE])
return
SUMMARIZE(
    'Table (2)','Table (2)'[ORA ID],
    "project id",CALCULATE(MIN('Table (2)'[PROJECT ID]),'Table (2)'[END_DATE]=MAX('Table (2)'[END_DATE]))
,"s",MAX('Table (2)'[END_DATE])
)

 

View solution in original post

4 REPLIES 4
Dangar332
Super User
Super User

hi, @Przem 

try below

 

Table 2 = 
GROUPBY('Table (2)','Table (2)'[ORA ID],"project id",MAXX(CURRENTGROUP(),'Table (2)'[PROJECT ID]),"end date",MAXX(CURRENTGROUP(),'Table (2)'[END_DATE]))

 

or

 

Table 3 = 
var a = MAX('Table (2)'[END_DATE])
return
SUMMARIZE(
    'Table (2)','Table (2)'[ORA ID],
    "project id",CALCULATE(MIN('Table (2)'[PROJECT ID]),'Table (2)'[END_DATE]=MAX('Table (2)'[END_DATE]))
,"s",MAX('Table (2)'[END_DATE])
)

 

Second option works, thank you so much 🙂

123abc
Community Champion
Community Champion

If you want to keep all the columns in your result table, including the PROJECT ID, you can achieve this by using the SUMMARIZE function in DAX. Here's an example of how you can modify your formula:

 

ResultTable =
SUMMARIZE(
'Data',
'Data'[ORA ID],
"LatestTime", MAXX(CURRENTGROUP(), 'Data'[END_DATE]),
"LatestProjectID",
CALCULATE(
VALUES('Data'[PROJECT ID]),
'Data'[END_DATE] = MAXX(CURRENTGROUP(), 'Data'[END_DATE])
)
)

Thank you, 
There is an error related to CURRENTGROUP() - "Parameter is not the correct type"

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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