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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Afonichkina
New Member

Add custom subtotal rows

Dear all,

 

I have raw data: account codes and values. The challenge is to show custom subtotals in the same table as the accoundtcodes. Use case: finance (profit and loss statement with groupings of accounts)

Example for what I have:

Table 1

Code   Value

0010     6

0020     4

0030     7

0040    10

 

Example for what I wish:

Table 3

Code   Value

0010     6

0020     4

0025     10

0030     7

0040    10

 

Is there any way to add Code 0025 as a new row with a calcultion "0010" + "0020"?

I use following workaround:

1) build a table 2 with SUMMARIZE-function on filtered codes 0010 and 0020 and give the rows a label "0025"

2) unite a table 1 and table 2 in the table 3

Is this the only workaround? In this case i would need an extra table for any new row. Is this correct?

Thank you for the help!

 

BR

Nadia 

1 ACCEPTED SOLUTION

@Afonichkina That would work or if you had an additional column in your data or if you added a calculated column in M code or as a calculated column in DAX, such as:

Group Code Column = 
  SWITCH(TRUE(),
    [Code] = "0010" || [Code] = "0020","0025",
    [Code]
  )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Afonichkina,

You can also try to create a calculated table to add additional rows to your table and write a condition formula to summarize results on specific rows.

Table = 
SELECTCOLUMNS (
    UNION (
        T1,
        DATATABLE (
            "Code", STRING,
            "Value", DOUBLE,
            {
                { "0025", -1 },
                { "0045", -1 }
            }
        )
    ),
    "Code", [Code],
    "Value",
        SWITCH (
            [Code],
            "0025", CALCULATE ( SUM ( T1[Value] ), T1[Code] IN { "0020", "0010" } ) ,
            "0045", CALCULATE ( SUM ( T1[Value] ), T1[Code] IN { "0030", "0040" } ) ,
            [Value]
        )
)

14.png

Regards,

Xiaoxin Sheng

Afonichkina
New Member

@Greg_Deckler  much appreciated! I will try this out.

Afonichkina
New Member

@Greg_Deckler you mean, to use a "matching table"?

Code    Group code

0010     0025

0020     0025

0030     0030

0040     0040

@Afonichkina That would work or if you had an additional column in your data or if you added a calculated column in M code or as a calculated column in DAX, such as:

Group Code Column = 
  SWITCH(TRUE(),
    [Code] = "0010" || [Code] = "0020","0025",
    [Code]
  )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Community Champion
Community Champion

@Afonichkina - Well, you could do that or if you have some kind of "group" code where you could use a matrix, you could group and sum things that way. 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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 Kudoed Authors