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

Summing and Averaging By Matrix Level

Hello. Working in different levels of a matrix. The levels are Date->Hour->City->Locations. City names are blocked out in red.

I am trying to sum all the values of the locations level so that the city level shows that sum (1,092 & 377 in example below). Then sum at the hour level by city (1469,1400,1491) and then average at the date level. (1469+1400+1491/3=1,453). Basically everything in the photo is correct except that I want to average the date level by hour instead of summing all the hours together. Thanks!

 
Astargle95_1-1706117315149.png

 

Current code for the No Checks column:

Avg NC =
SWITCH (
    TRUE (),
    NOT ISFILTERED ( 'Table'[DATA_HR] ), AVERAGEX ( VALUES ( 'Table'[DATA_HR] ), CALCULATE ( SUM ( 'Table'[NC_COUNT] ) ) ),
    SUM( ( 'Table'[NC_COUNT] )
))

 

1 ACCEPTED SOLUTION
Daniel29195
Super User
Super User

@Anonymous 

Hello, 

 

use isinscope ()  function..

 

and change the calculation depending on which level you are in the matrix. 

 

 

NB :  when using isinscope start from the lowest level , check below .

 

measure = 

switch( 

true() , 

isinscope(location ) ,  -- your calcultion , 

isinscope(cityt) ,  -- your calcultion , 

isinscope(hour) ,  -- average 

isinscope(date) ,  -- your calcultion , 

 

 

 

 

If my response has successfully addressed your issue kindly consider marking it as the accepted solution! This will help others find it quickly. Dont forget to hit that  thumbs up button 🫡👍

View solution in original post

1 REPLY 1
Daniel29195
Super User
Super User

@Anonymous 

Hello, 

 

use isinscope ()  function..

 

and change the calculation depending on which level you are in the matrix. 

 

 

NB :  when using isinscope start from the lowest level , check below .

 

measure = 

switch( 

true() , 

isinscope(location ) ,  -- your calcultion , 

isinscope(cityt) ,  -- your calcultion , 

isinscope(hour) ,  -- average 

isinscope(date) ,  -- your calcultion , 

 

 

 

 

If my response has successfully addressed your issue kindly consider marking it as the accepted solution! This will help others find it quickly. Dont forget to hit that  thumbs up button 🫡👍

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Kudoed Authors