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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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