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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
darinme
Employee
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/

 

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])

 

 

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/

 

 

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors