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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request 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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.