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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Sum of Rows

Hi, I have a matrix table but the subtotals for each row is wrong.

 

 

The current table that i have right now is this:

Afiq_Danial_1-1666677310513.png

 

This is my desired outcome:

Afiq_Danial_2-1666677350222.png

 

To get the values, I've created a measure and this is my calculation:

Test =
VAR ThisDate = SELECTEDVALUE ( 'Date'[Date] )
VAR Hours =
  CALCULATE (
  (100 - SUM ( 'Hours'[Loading])) * 0.08,
  FILTER (
  'Hours',
  'Hours'[Job Start Date] <= ThisDate &&
  'Staff Booking'[End date] >= ThisDate &&
)
)
 
Return Hours

 

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but please try something like below whether it suits your requirement.

 

 

Test =
VAR ThisDate =
    SELECTEDVALUE ( 'Date'[Date] )
VAR Hours =
    SUMX (
        DISTINCT ( 'Date'[Date] ),
        CALCULATE (
            ( 100 - SUM ( 'Hours'[Loading] ) ) * 0.08,
            FILTER (
                'Hours',
                'Hours'[Job Start Date] <= ThisDate
                    && 'Staff Booking'[End date] >= ThisDate
            )
        )
    )
RETURN
    Hours

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Hi I think you are close to the solution. However right now, i realised that the total sum of rows are "8 * number of date" 

Hi @Anonymous ,

 

Has your problem been solved? If not solved, can you share with me some screenshots of your data after hiding sensitive information?

 

Best regards,

Yadong Fang

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.