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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Grouping Columns

I've got a table that organizes like the following:

DateTypeA1A2B1B2B3
1/1/2022Red23133
1/2/2022Blue32202
1/3/2022Green23331

 

I need to create a table that groups together the A and B columns so it looks like the following:

DateTypeAB
1/1/2022Red56
1/2/2022Blue52
1/3/2022Green57
    

 

How would I do this in DAX?

 

Thanks!!

6 REPLIES 6
FreemanZ
Super User
Super User

hi @Anonymous 

not sure if i fullly get you. you can create a table like this:

SumTable2 =
SELECTCOLUMNS(
    data, 
    "Date", data[Date], 
    "Type", data[Type], 
    "A", [A1]+[A2], 
    "B", [B1]+[B2]+[B3]
)

i works like this:

FreemanZ_0-1672839516762.png

Anonymous
Not applicable

Are these columns name (Ax, Bx) going to be fixed or dynamic?

 

Why not Power Query?

Anonymous
Not applicable

I have no problem with PQ, I just started the process in DAX, so that was the direction I figured I'd ask for. But if you know the solution using PQ, please let me know!

Anonymous
Not applicable

Here's PQ:

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ31DcyMDJS0lEKSk0BkiCWMRAbQmljpVgdkDIjmDKnnNJUqJwRFBuAaYg6Y5g696LU1DwkA43hBsfGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Type = _t, A1 = _t, A2 = _t, B1 = _t, B2 = _t, B3 = _t]),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Date", "Type"}, "Attribute", "Value"),
#"Split Column by Position" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByPositions({0, 1}, false), {"Attribute.1", "Attribute.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Position",{{"Attribute.1", type text}, {"Attribute.2", Int64.Type}, {"Value", Int64.Type}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Attribute.2"}),
#"Grouped Rows" = Table.Group(#"Removed Columns", {"Date", "Type", "Attribute.1"}, {{"Total", each List.Sum([Value]), type number}}),
#"Pivoted Column" = Table.Pivot(#"Grouped Rows", List.Distinct(#"Grouped Rows"[Attribute.1]), "Attribute.1", "Total", List.Sum)
in
#"Pivoted Column"

tamerj1
Super User
Super User

Hi @Anonymous 
Is this a source table or a matrix visual? Are you looking for a measure or a calculated table?

Anonymous
Not applicable

This is a source table, and I'm looking to create a calculated table. Thanks!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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