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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Average data by a Category (region) and a date

Hello all,

 

I've been looking over the forums for a bit today to try and figure this out but haven't found something that quite lines up.  

 

THis post is close but no cigar.

 

https://community.powerbi.com/t5/Desktop/Average-by-category-AND-date/m-p/683199#M329137

 

I want to get an average monthly headcount (over the past year, rolling 12 not calendar) by Region.  Each calculation I've tried to do this results in an average for each location, not it's region.  When I pull the data into a table and I just have Region and Headcount it still just averages by location.  

 

I want to take the results of this and feed this into another calculation.

 

I have data that looks like below:

 

DateLocationRegionHeadcount
1/1/2019aNorth10
1/1/2019aSouth30
1/1/2019bNorth15
1/1/2019bSouth100
2/1/2019aNorth15
2/1/2019aSouth40
2/1/2019bNorth20
2/1/2019bSouth78
3/1/2019aNorth30
3/1/2019aSouth23
3/1/2019bNorth90
3/1/2019bSouth14

 

Now I would like to Group and Average like below:

North   
Jan25  
Feb35Monthly Average
March12060 
    
    
South Monthly Average
Jan13095 
Feb118  
March37  
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Create a new column

YearMonth = (YEAR(TableName[Date])*100)+MONTH(TableName[Date])
 
Then Create this measure
 
Average HC by Region = DIVIDE(
SUM(TableName[Headcount]),
DISTINCTCOUNT(TableName[YearMonth])
)
 
You can display this measure in table with Region.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous ,

 

Create a new column

YearMonth = (YEAR(TableName[Date])*100)+MONTH(TableName[Date])
 
Then Create this measure
 
Average HC by Region = DIVIDE(
SUM(TableName[Headcount]),
DISTINCTCOUNT(TableName[YearMonth])
)
 
You can display this measure in table with Region.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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