SUMX and Subtotals Not Adding Up

TheMacroNoob

Board Regular
Joined
Aug 5, 2022
Messages
52
Office Version
  1. 365
Platform
  1. Windows
Hello experts,

In my Power BI report I am trying to do a calculation on all rows in a table, then be able to correctly add them up in the subtotal lines by whatever grouping I am using. In my case, the final grouping I have in Matrix rows is 'Calendar'[EOM], which is not being used in the measure, and that is the only subtotal line that isn't mathing. Despite correct relationships being set up, is this what is causing the issue, and do I need to adjust my measure to be able to be grouped outside of ClosedClinic fields/Calendar[Date]?

I have the following measure in Power BI:

Estimated Lost Visits =

Excel Formula:
SUMX(
    ClosedClinics,
    VAR AvgVisitsR90 = 
        CALCULATE(
            AVERAGE(VisitType[Total Visits]),
            VisitType[Total Visits] > 0,
            DATESINPERIOD('Calendar'[Date],LASTDATE('Calendar'[Date]),-90,DAY),
            WEEKDAY('Calendar'[Date],2) = WEEKDAY(MAX('Calendar'[Date]),2)
        )
    VAR AvgHrsWeekday =
            CALCULATE(
            AVERAGE(VisitType[Hours]),
            VisitType[Total Visits] > 0,
            DATESINPERIOD('Calendar'[Date],LASTDATE('Calendar'[Date]),-90,DAY),
            WEEKDAY('Calendar'[Date],2) = WEEKDAY(MAX('Calendar'[Date]),2)
        )
    VAR VisitsPerHour = DIVIDE(AvgVisitsR90, AvgHrsWeekday, 2.8)
    RETURN 
    VisitsPerHour * ClosedClinics[True Hours Lost]
)

In a Matrix, I am using the following fields, all but one being used in the measure:
1702492883777.png
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
There’s a section in my article that covers “totals don’t add up”, but I suggest you read the entire article
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,954
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top