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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
marcio_fornari
Resolver I
Resolver I

Add new row with accumulate in Matrix

Hi, 

It's possible add a new a row in Matrix with the Month Accumulate? 
I have the total and i would like a new row with the accumulate. 

Like this example:

 

acc.png

My Example file:

Example.pbix 

 

Thank you.

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @marcio_fornari ,

I updated your sample pbix file(see attachment), please check whether that is what you want.

1. Create a calculated table with below formula

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

yingyinr_0-1635834819166.png

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

yingyinr_1-1635834972152.png

Best Regards

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.

View solution in original post

4 REPLIES 4
v-yiruan-msft
Community Support
Community Support

Hi @marcio_fornari ,

I updated your sample pbix file(see attachment), please check whether that is what you want.

1. Create a calculated table with below formula

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

yingyinr_0-1635834819166.png

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

yingyinr_1-1635834972152.png

Best Regards

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.

Hi, it's work like a charm! 
Thank so much! 

 

CNENFRNL
Community Champion
Community Champion

Simple enough, but first rectify the date table,

 

Date = CALENDAR("1/1/2016", "12/31/2018")

 

Screenshot 2021-10-29 061622.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

amitchandak
Super User
Super User

@marcio_fornari , You may have to create a custom table with that data to get this

 

refer

https://community.powerbi.com/t5/Desktop/Calculated-Row-in-Matrix/m-p/249519

https://community.powerbi.com/t5/Desktop/Power-BI-desktop-create-a-Calculated-Row-in-Matrix-Visualis...

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.