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
Vayne-Daryl
New Member

Matrix Row and Columns Subtotal are not calculating correctly

Hello Good Day Everyone 🙂

I am struggling to find a solution for the incorrect matrix sub total. Hope someone could help me out or advice a workaround somehow. Your help is very much appreciated. Thanks in advance 🙂

I have these sample data below:

Our fiscal year starts in July, so in this case if the Start Date is July the Value should be copied to the rest of the months until June but there are instances that Start Date begins in the middle of the fiscalyear like for example January, so the Value in January should be copied until June and the previous months should display 0.

VayneDaryl_2-1722340318313.png


I have created a calendar table to display the necessary output below:
And this is the current result of my measure. Notice that the totals are incorrect.

VayneDaryl_1-1722339770649.png

 

This is the measure that i used:

Test Measure =
            var c =
                SUMX (
                    FILTER (
                        ALL ( 'ApplicationCost' ),
                        'ApplicationCost'[ApplicationName] = SELECTEDVALUE('ApplicationCost'[ApplicationName]) &&
                        'ApplicationCost'[Control Number] = SELECTEDVALUE('ApplicationCost'[Control Number]) &&
                        'ApplicationCost'[FiscalYear] = SELECTEDVALUE('Calendar'[Fiscal Year])
                    ),
                    'ApplicationCost'[StartDateFiscalMonth]
                )
RETURN
            SUMX
                (
                SUMMARIZE(
                            FILTER (
                                    'ApplicationCost',
                                    'ApplicationCost'[FiscalYear] = yr
                                ),
                            'ApplicationCost'[ApplicationName],
                            'ApplicationCost'[Control Number],
                            "TotalValue", SUM('ApplicationCost'[Value])
                        ),  IF(MAX('support_tblCalendar_trendline'[Fiscal Month]) >= c,[TotalValue],0)
            )
1 ACCEPTED SOLUTION
anmolmalviya05
Memorable Member
Memorable Member

Hi @Vayne-Daryl, Hope you are doing good!

Please try the below measures

 

Test Measure =
VAR CurrentFiscalYear = SELECTEDVALUE('Calendar'[Fiscal Year])
VAR StartFiscalMonth =
CALCULATE(
MIN('ApplicationCost'[StartDateFiscalMonth]),
FILTER(
'ApplicationCost',
'ApplicationCost'[ApplicationName] = SELECTEDVALUE('ApplicationCost'[ApplicationName]) &&
'ApplicationCost'[Control Number] = SELECTEDVALUE('ApplicationCost'[Control Number]) &&
'ApplicationCost'[FiscalYear] = CurrentFiscalYear
)
)
VAR Result =
SUMX(
'ApplicationCost',
IF(
'ApplicationCost'[FiscalYear] = CurrentFiscalYear &&
'ApplicationCost'[StartDateFiscalMonth] <= MAX('Calendar'[Fiscal Month]),
'ApplicationCost'[Value],
0
)
)
RETURN
Result

 

 

 

 

Final Measure =
SUMX(
SUMMARIZE(
'ApplicationCost',
'ApplicationCost'[ApplicationName],
'ApplicationCost'[Control Number],
"MonthValue", [Test Measure]
),
[MonthValue]
)

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!

 

View solution in original post

4 REPLIES 4
anmolmalviya05
Memorable Member
Memorable Member

Hi @Vayne-Daryl, Hope you are doing good!

Please try the below measures

 

Test Measure =
VAR CurrentFiscalYear = SELECTEDVALUE('Calendar'[Fiscal Year])
VAR StartFiscalMonth =
CALCULATE(
MIN('ApplicationCost'[StartDateFiscalMonth]),
FILTER(
'ApplicationCost',
'ApplicationCost'[ApplicationName] = SELECTEDVALUE('ApplicationCost'[ApplicationName]) &&
'ApplicationCost'[Control Number] = SELECTEDVALUE('ApplicationCost'[Control Number]) &&
'ApplicationCost'[FiscalYear] = CurrentFiscalYear
)
)
VAR Result =
SUMX(
'ApplicationCost',
IF(
'ApplicationCost'[FiscalYear] = CurrentFiscalYear &&
'ApplicationCost'[StartDateFiscalMonth] <= MAX('Calendar'[Fiscal Month]),
'ApplicationCost'[Value],
0
)
)
RETURN
Result

 

 

 

 

Final Measure =
SUMX(
SUMMARIZE(
'ApplicationCost',
'ApplicationCost'[ApplicationName],
'ApplicationCost'[Control Number],
"MonthValue", [Test Measure]
),
[MonthValue]
)

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!

 

Hello anmolmalviya05,
Thank you so much for the help I really appreciate it and your solution works like a charm 🙂
I have notice that you have created another measure which solved the issue.
Thanks again for the support and sharing your ideas 🙂

v-yaningy-msft
Community Support
Community Support

Hi, @Vayne-Daryl 

 

Didn't simulate your problem, you can provide pbix files without sensitive information for testing, feel free to help you about this problem.

Best Regards,
Yang

Community Support Team



Hi Yang,
Thank you so much for your reply but unfortunately our system is blocking any uploads to external resources. But it seems to me that the solution from anmolmalviya05 solved the issue 🙂
Thanks Again.

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!

November Carousel

Fabric Community Update - November 2024

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

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.