cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Stuznet Member
Member

Matrix Row Subtotal Incorrect

Hi guys,

I'm having trouble with the Matrix Row Subtotal summing incorrectly. Can you help? 

Here is the dummy report.

 

Capture.PNG

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
v-lid-msft New Contributor
New Contributor

Re: Matrix Row Subtotal Incorrect

Hi @Stuznet ,

 

I am so sorry that I missed it, now I have fixed it, try to use following measure.

 

Measure =
VAR r3total =
    SUMX (
        ADDCOLUMNS (
            'Month Sort',
            "1", CALCULATE ( [Row1] ),
            "2", CALCULATE ( [Row2] )
        ),
        ( [1] + [2] ) * ( 13 - [Month Num] )
    )
RETURN
    IF (
        ISINSCOPE ( 'ROW'[Category] ),
        SWITCH (
            TRUE (),
            MAX ( 'ROW'[Category] ) = "ROW1", IF (
                ISINSCOPE ( 'Month Sort'[Month] ),
                CALCULATE ( [Row1] ),
                CALCULATE (
                    [Row1],
                    FILTER ( 'Data', Data[Month Num] + 1 >= MONTH ( TODAY () ) )
                )
            ),
            MAX ( 'ROW'[Category] ) = "ROW2", IF (
                ISINSCOPE ( 'Month Sort'[Month] ),
                CALCULATE ( [Row2] ),
                CALCULATE (
                    [Row2],
                    FILTER ( 'Data', Data[Month Num] + 2 <= MONTH ( TODAY () ) )
                )
            ),
            MAX ( 'ROW'[Category] ) = "ROW3", IF ( ISINSCOPE ( 'Month Sort'[Month] ), CALCULATE ( [Row3] ), r3total )
        ),
        CALCULATE ( [Row1] ) + CALCULATE ( [Row2] ) + r3total
    )

1.PNG

 

BTW, pbix as attached.

 

Best regards,

Community Support Team _ Dong Li
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

6 REPLIES 6
Nathaniel_C Super Contributor
Super Contributor

Re: Matrix Row Subtotal Incorrect

@Stuznet 

Are you using a measure?

 

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel

Stuznet Member
Member

Re: Matrix Row Subtotal Incorrect

Yes, I'm using a measure. I provided a dummy report, feel free take a look

v-lid-msft New Contributor
New Contributor

Re: Matrix Row Subtotal Incorrect

Hi @Stuznet ,

 

This is caused by the max funcution in your measure while the total means all the month. You can change the measure to the following.

 

Measure = 
IF (
    ISINSCOPE ( 'ROW'[Category] ),
    SWITCH (
        TRUE (),
        MAX ( 'ROW'[Category] ) = "ROW1", IF (
            ISINSCOPE ( 'Month Sort'[Month] ),
            CALCULATE ( [Row1] ),
            CALCULATE (
                [Row1],
                FILTER ( 'Data', Data[Month Num] + 1 >= MONTH ( TODAY () ) )
            )
        ),
        MAX ( 'ROW'[Category] ) = "ROW2", IF (
            ISINSCOPE ( 'Month Sort'[Month] ),
            CALCULATE ( [Row2] ),
            CALCULATE (
                [Row2],
                FILTER ( 'Data', Data[Month Num] + 2 <= MONTH ( TODAY () ) )
            )
        ),
        MAX ( 'ROW'[Category] ) = "ROW3", IF (
            ISINSCOPE ( 'Month Sort'[Month] ),
            CALCULATE ( [Row3] ),
            CALCULATE (
                [Row1],
                FILTER ( 'Data', Data[Month Num] + 1 >= MONTH ( TODAY () ) )
            )
                + CALCULATE (
                    [Row2],
                    FILTER ( 'Data', Data[Month Num] + 2 <= MONTH ( TODAY () ) )
                )
        )
    ),
    CALCULATE ( [Row1] ) + CALCULATE ( [Row2] )
        + CALCULATE ( [Row3] )
)

We use the inscope to judge the total and calculate different value for different scope.

 

15.PNG

 

If it doesn't meet your requirement, kindly share your expected result to me based on your dummy report.

 

BTW, pbix as attached.

 

Best regards,

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

Stuznet Member
Member

Re: Matrix Row Subtotal Incorrect

Hi @v-lid-msft,

This is a great start but Row 3 total 780 is not correct it should be 3640. Any idea how can I correct it?

Thanks
v-lid-msft New Contributor
New Contributor

Re: Matrix Row Subtotal Incorrect

Hi @Stuznet ,

 

I am so sorry that I missed it, now I have fixed it, try to use following measure.

 

Measure =
VAR r3total =
    SUMX (
        ADDCOLUMNS (
            'Month Sort',
            "1", CALCULATE ( [Row1] ),
            "2", CALCULATE ( [Row2] )
        ),
        ( [1] + [2] ) * ( 13 - [Month Num] )
    )
RETURN
    IF (
        ISINSCOPE ( 'ROW'[Category] ),
        SWITCH (
            TRUE (),
            MAX ( 'ROW'[Category] ) = "ROW1", IF (
                ISINSCOPE ( 'Month Sort'[Month] ),
                CALCULATE ( [Row1] ),
                CALCULATE (
                    [Row1],
                    FILTER ( 'Data', Data[Month Num] + 1 >= MONTH ( TODAY () ) )
                )
            ),
            MAX ( 'ROW'[Category] ) = "ROW2", IF (
                ISINSCOPE ( 'Month Sort'[Month] ),
                CALCULATE ( [Row2] ),
                CALCULATE (
                    [Row2],
                    FILTER ( 'Data', Data[Month Num] + 2 <= MONTH ( TODAY () ) )
                )
            ),
            MAX ( 'ROW'[Category] ) = "ROW3", IF ( ISINSCOPE ( 'Month Sort'[Month] ), CALCULATE ( [Row3] ), r3total )
        ),
        CALCULATE ( [Row1] ) + CALCULATE ( [Row2] ) + r3total
    )

1.PNG

 

BTW, pbix as attached.

 

Best regards,

Community Support Team _ Dong Li
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

Stuznet Member
Member

Re: Matrix Row Subtotal Incorrect

Thank you so much! You’re da best! Smiley Happy

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 85 members 2,754 guests
Please welcome our newest community members: