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
DevM01
Helper I
Helper I

Add more columns to the result of GROUPBY

I am creating a table using GROUPBY, however, I want to add more columns from the source to this result table. I don't want to group by these columns, I just want to add them to the end result. 

 

For example I have this: 

 

GROUPBY(entries, entries[accountId])

 

But I would like to add more columns (not to be grouped by) to the end result of this.. If I do something like this: 

GROUPBY(entries, entries[accountId], entries[newfield])

 

It will also be grouped by the new column. How can we do this? 

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @DevM01 ,

In most cases GROUPBY() is simliar with SUMMAZIRE(). When you create table using GROUPBY(entries,entries[accountId]), the table will return a summarize table with distinct ID values.

If you want to add more columns based on this summarized table, you can save it as variable and use ADDCOLUMNS() to add new columns for it which is calulated from the source table. Here is the sample:

Test =
VAR tab =
    GROUPBY ( 'Table', 'Table'[ID] )
VAR tb =
    ADDCOLUMNS (
        tab,
        "a",
            CALCULATE (
                MAX ( 'Table'[Value] ),
                FILTER ( tab, [ID] = EARLIER ( 'Table'[ID] ) )
            )
    )
RETURN
    tb

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yingjl
Community Support
Community Support

Hi @DevM01 ,

In most cases GROUPBY() is simliar with SUMMAZIRE(). When you create table using GROUPBY(entries,entries[accountId]), the table will return a summarize table with distinct ID values.

If you want to add more columns based on this summarized table, you can save it as variable and use ADDCOLUMNS() to add new columns for it which is calulated from the source table. Here is the sample:

Test =
VAR tab =
    GROUPBY ( 'Table', 'Table'[ID] )
VAR tb =
    ADDCOLUMNS (
        tab,
        "a",
            CALCULATE (
                MAX ( 'Table'[Value] ),
                FILTER ( tab, [ID] = EARLIER ( 'Table'[ID] ) )
            )
    )
RETURN
    tb

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Nathaniel_C
Community Champion
Community Champion

Hi @DevM01 
You might look into SUMMARIZECOLUMNS()
https://docs.microsoft.com/en-us/dax/summarizecolumns-function-dax 

Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




mahoneypat
Microsoft Employee
Microsoft Employee

Can you show an example input and output table with data?  You can addcolumns by providing a name and aggregation for the newfield column.

 

Regards,

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


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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors