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
darinme
Microsoft Employee
Microsoft Employee

creating a new table that sums values from rows of another table that have the same dateid

*updated for clarity*

Hi,

 

I want to create a table that sums values from rows of a different table where the sum is for the desired values from the same date.

 

Best way I can explain:

From: 

DateIdSettingNameTotalCount
20210901Value150
20210901Value220
20210901Value3111
20210902Value140
20210902Value210
20210901Value3222

Create a new table like this (where I only bring over the sum for Value 1 and Value 2):

DateIdSettingNameTotalCount
20210901Value1Value270
20210902Value1Value250

 

Note: SettingName value can be static text but can also go with concatenated.

1 ACCEPTED SOLUTION

Hi @darinme 

 

Try this to exclude Value3 from the new table:

 

Table 2 = 
SUMMARIZE (
    filter('Table','Table'[SettingName]<>"Value3"),
    'Table'[DateId],
    "SettingName", CONCATENATEX ( 'Table', 'Table'[SettingName], "" ),
    "TotalCount", SUM ( 'Table'[TotalCount] )
)

 

DATA :

VahidDM_0-1638237514206.png

 

Output:

 

VahidDM_1-1638237534035.png

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

View solution in original post

6 REPLIES 6
VahidDM
Super User
Super User

HI @darinme 

 

If you want a DAX code to create a new table, try this:

 
 

https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-calculated-tables

 

 

Table 2 = 
SUMMARIZE (
    'Table',
    'Table'[DateId],
    "SettingName", CONCATENATEX ( 'Table', 'Table'[SettingName], "" ),
    "TotalCount", SUM ( 'Table'[TotalCount] )
)

 

 

Output:

 

VahidDM_3-1638235321822.png

 

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

darinme
Microsoft Employee
Microsoft Employee

Thanks for that and would be perfect to my posted question.  I realize that I negelcted to state there are other SettingNames values I do not want to include.  
Updating my table example where I do not want to bring over Value3 into the new table.

DateIdSettingNameTotalCount
20210901Value150
20210901Value220
20210901Value3111
20210902Value140
20210902Value210
20210901Value3222

Create a new table like this:

DateIdSettingNameTotalCount
20210901Value1Value270
20210902Value1Value250
Vera_33
Resident Rockstar
Resident Rockstar

Hi @darinme 

 

When you said a new table, it is a table you go with Power Query or DAX Calculated table, or a table visual?

 

You can groupby in M

Vera_33_0-1638232989705.png

Table.Group(#"Changed Type", {"DateId"}, {{"newSettingName", each Text.Combine(_[SettingName],";")}, {"newTotalCount", each List.Sum([TotalCount]), type nullable number}})

Or go with measures for a table visual

Vera_33_1-1638233022469.png

newName = CONCATENATEX('Table','Table'[SettingName],";")

newTotalCount = SUM('Table'[TotalCount])

 

 

darinme
Microsoft Employee
Microsoft Employee

Thank you.  I prefer DAX table.  I also neglected to state there are other SettingNames values I do not want to include.  
Updating my table example where I do not want to bring over Value3 into the new table.

DateIdSettingNameTotalCount
20210901Value150
20210901Value220
20210901Value3111
20210902Value140
20210902Value210
20210901Value3222

Create a new table like this:

DateIdSettingNameTotalCount
20210901Value1Value270
20210902Value1Value250

Hi @darinme 

 

Try this to exclude Value3 from the new table:

 

Table 2 = 
SUMMARIZE (
    filter('Table','Table'[SettingName]<>"Value3"),
    'Table'[DateId],
    "SettingName", CONCATENATEX ( 'Table', 'Table'[SettingName], "" ),
    "TotalCount", SUM ( 'Table'[TotalCount] )
)

 

DATA :

VahidDM_0-1638237514206.png

 

Output:

 

VahidDM_1-1638237534035.png

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

darinme
Microsoft Employee
Microsoft Employee

That does it!  Thanks.  I also discovered that I can do the inverse using 'IN' to only select the fields I want.  Useful when there are many values and only wnat a few.

 

Table 2 = 
SUMMARIZE (
    filter('Table','Table'[SettingName] IN {"Value1","Value2")},
    'Table'[DateId],
    "SettingName", CONCATENATEX ( 'Table', 'Table'[SettingName], "" ),
    "TotalCount", SUM ( 'Table'[TotalCount] )

 

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.