cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

New Member

## Add Subtotal Rows for selected amount

Hi all,

I am trying to get the subtotal for selected rows but I have no idea on how to do it.

Example for what I have :

Example for what I wish :

Is there any way that I can add in subtotal which I highlighted in bold (Total Revenue, Profit before tax and Profit after tax)?

Thank you for you help 🙂

1 ACCEPTED SOLUTION
Community Support

Hi  @cfg_fang,

Add new row with accumulate in Matrix

1. Create a calculated table with below formula

``Table = UNION(VALUES('Sales'[Product]),ROW("Product","XMonth Accumulate")) ``

2. Create two measures as below to get the sum of sales

``````Measure =
VAR _selmonthname =
SELECTEDVALUE ( 'Date'[MontName] )
VAR _selmonthnum =
CALCULATE (
MAX ( 'Date'[MontNumber] ),
FILTER ( 'Date', 'Date'[MontName] = _selmonthname )
)
RETURN
SWITCH (
SELECTEDVALUE ( 'Table'[Product] ),
"XMonth Accumulate",
SUMX (
FILTER (
ALLSELECTED ( 'Sales' ),
MONTH ( 'Sales'[Date] ) <= VALUE ( _selmonthnum )
),
[Sales (Selected Month)]
),
SUMX (
FILTER ( 'Sales', 'Sales'[Product] = SELECTEDVALUE ( 'Table'[Product] ) ),
[Sales (Selected Month)]
)
)``````
``````Month Accumulate =
IF (
ISINSCOPE ( 'Table'[Product] ),
SUMX ( VALUES ( 'Table'[Product] ), [Measure] ),
[Sales (Selected Month)]
)``````

3. Create a matrix visual (Rows: field Product of Table   Column: field MonthName in Date table  Values: [Month Accumulate] )

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 REPLIES 3
Community Support

Hi  @cfg_fang,

Add new row with accumulate in Matrix

1. Create a calculated table with below formula

``Table = UNION(VALUES('Sales'[Product]),ROW("Product","XMonth Accumulate")) ``

2. Create two measures as below to get the sum of sales

``````Measure =
VAR _selmonthname =
SELECTEDVALUE ( 'Date'[MontName] )
VAR _selmonthnum =
CALCULATE (
MAX ( 'Date'[MontNumber] ),
FILTER ( 'Date', 'Date'[MontName] = _selmonthname )
)
RETURN
SWITCH (
SELECTEDVALUE ( 'Table'[Product] ),
"XMonth Accumulate",
SUMX (
FILTER (
ALLSELECTED ( 'Sales' ),
MONTH ( 'Sales'[Date] ) <= VALUE ( _selmonthnum )
),
[Sales (Selected Month)]
),
SUMX (
FILTER ( 'Sales', 'Sales'[Product] = SELECTEDVALUE ( 'Table'[Product] ) ),
[Sales (Selected Month)]
)
)``````
``````Month Accumulate =
IF (
ISINSCOPE ( 'Table'[Product] ),
SUMX ( VALUES ( 'Table'[Product] ), [Measure] ),
[Sales (Selected Month)]
)``````

3. Create a matrix visual (Rows: field Product of Table   Column: field MonthName in Date table  Values: [Month Accumulate] )

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Memorable Member

Hi,

Not sure if it is a good idea,

But I add the 3 separate column in Power Query :

- the first one is :

-The second one :

- The third one :

In the end I have this table :

Then Create the Matrix visual (the right one is with all groups) as below :

Mahyartf
Super User

@cfg_fang , What I have done for that is aI appended a table with those account names

Then I created a measure

if( Max(Table[Account Name]) <> "Profit before tax" ,

[Measure] , calculate([Measure], filter(allselected(Table[Account Name]) , Table[Account Group] in {"Income"} ) )
- calculate([Measure], filter(allselected(Table[Account Name]) , Table[Account Group] in {"Expense"} ) )
)

You can use individual account names too in place groups. I have given in for that in code

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

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

#### Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

#### Fabric Community Update - September 2024

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

Top Solution Authors
Top Kudoed Authors