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

The Fabric Community site will be in read-only mode on Monday, Feb 24 from 12:01 AM to 8 AM PST for scheduled upgrades.

Reply
Anonymous
Not applicable

Group rows with same and different values.

Hi, I am trying to group/summarize rows with the same values. The problem is some of rows are a match for 2/3 of the columns which screws up my data. 

 

Example: 

Before query is executed

 

EmailDept NumberCost
name@mail.com56562.00
name2@mail.com12126.00
name@mail.com56563.00
name@mail.com56562.00

 

After query is executed

EmailDept NumberCost
name@mail.com56564.00
name2@mail.com12126.00
name@mail.com56563.00

 

I need the similar rows with different cost to be rolled up as well. I am using a simple summarize query to achieve this but how can I get the rows with different cost to be grouped in as well?

 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @Anonymous 

try to create a calculated table like:

SumTable =
ADDCOLUMNS(
    SUMMARIZE(
        TableName,
        TableName[Email],
        TableName[Dept Number]
    ),
    "Cost",
    CALCULATE(SUM(TableName[Cost]))
)

 

Also, in Power Query Editor, you can try to Groupby the query, 

https://learn.microsoft.com/en-us/power-query/group-by

 

View solution in original post

5 REPLIES 5
FreemanZ
Super User
Super User

hi @Anonymous 

try to create a calculated table like:

SumTable =
ADDCOLUMNS(
    SUMMARIZE(
        TableName,
        TableName[Email],
        TableName[Dept Number]
    ),
    "Cost",
    CALCULATE(SUM(TableName[Cost]))
)

 

Also, in Power Query Editor, you can try to Groupby the query, 

https://learn.microsoft.com/en-us/power-query/group-by

 

Anonymous
Not applicable

That worked ! One more thing though im trying to add a date filter but Im getting an error that "," before cost is incorrect. Any Idea why? 

 

DEFINE VAR MAveragePrice =
ADDCOLUMNS (
CALCULATETABLE (
SUMMARIZE ( 'Usage details amortized',
'Usage details amortized'[Tags - copy.DepartmentNumber],
'Usage details amortized'[Tags - copy.OwnerEmail]),
Usage details amortized'[Date])>= DATE ( 2022, 12, 01 ) &&
'Usage details amortized'[Date] <= DATE ( 2022, 12, 31 )
),
"Cost",
CALCULATE(SUM('Usage details amortized'[Cost])),
)
EVALUATE
MAveragePrice

hi @Anonymous 

CALCULATETABLE seems unnecessary, or?

 

p.s. please consider @someone, to continue a discussion.

Anonymous
Not applicable

@FreemanZ Maybe. I've tried Omitting it but I'm sure I got the formatting wrong. Where do you suppose I put the date filter?

hi @Anonymous 

sorry, i mislook part of your previous code. In cases like that, the filtering shall apply outside of ADDCOLUMNS. 

try like:

 

DEFINE 
VAR MAveragePrice =
CALCULATETABLE (
    ADDCOLUMNS (
        SUMMARIZE ( 
            'Usage details amortized',
            'Usage details amortized'[Tags - copy.DepartmentNumber],
            'Usage details amortized'[Tags - copy.OwnerEmail]),
            'Usage details amortized'[Date]
        ),
        "Cost",
        CALCULATE(SUM('Usage details amortized'[Cost]))
    ),
    'Usage details amortized'[Date])>= DATE ( 2022, 12, 01 ) &&
    'Usage details amortized'[Date] <= DATE ( 2022, 12, 31 )
)
EVALUATE
MAveragePrice

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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