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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
BODMON
New Member

Daily Average as a Column in Matrix

Hello community!

 

I'm looking to create a table and add a daily average weekly column for the currently selected week, and a daily average weekly column for the previous week as a comparison.

 

Example of the Output table I'm looking for:

BODMON_0-1676661574806.png

 

 

 

I'm able to do everything highlighted in green no problem, but my challenge with this is adding that average weekly in the matrix table and having it displayed as a column rather than a row.

 

I have a date table that I created that has every day in the year and a value of 0 if it's a holiday and 1 if it's a business day.

So in the past I've used it to just sum the days between the two periods and then divide the total Tickets by the total number of business days in a period. This is to get the Daily Average so we can compare. 

 

Below are 2 sample data sets. The first has the Users and how many Tickets they've closed, and the other data is just the date table indicating if it's a business day or not. Any help would be appreciated! Thanks. 

 

Sample_User data

 

User

Ticket_date

Tickets

User11/1/20230
User1

1/2/2023

0
User1

1/3/2023

10
User1

1/4/2023

15
User1

1/5/2023

20
User1

1/6/2023

25
User1

1/9/2023

10
User1

1/10/2023

15
User1

1/11/2023

20
User11/12/202325
User11/13/202330
User11/16/202312
User11/17/202319
User11/18/202325
User11/19/202322
User11/20/202329
User11/23/202324
User11/24/202326
User11/25/202320
User11/26/202310
User11/27/202315
User2

1/2/2023

0
User2

1/3/2023

15
User2

1/4/2023

20
User2

1/5/2023

25
User2

1/6/2023

30
User2

1/9/2023

15
User2

1/10/2023

20
User2

1/11/2023

25
User21/12/202330
User21/13/202335
User21/17/202318
User21/18/202317
User21/19/202325
User21/20/202340
User21/23/202333
User21/24/202335
User21/25/202310
User21/26/202319
User21/27/202315
User3

1/2/2023

0
User3

1/3/2023

20
User3

1/4/2023

25
User3

1/5/2023

30
User3

1/6/2023

35
User3

1/9/2023

20
User3

1/10/2023

25
User3

1/11/2023

30
User31/12/202335
User31/13/202340
User31/17/202317
User31/18/202330
User31/19/202333
User31/20/202320
User31/23/202324
User31/24/202340
User31/25/202334
User31/26/202310
User31/27/202310

 

 

Sample_Date table

 

DateDayBusiness_DayWK_DaysWeek
01/01/2023Sunday041
01/02/2023Monday041
01/03/2023Tuesday141
01/04/2023Wednesday141
01/05/2023Thursday141
01/06/2023Friday141
01/07/2023Saturday041
01/08/2023Sunday051
01/09/2023Monday152
01/10/2023Tuesday152
01/11/2023Wednesday152
01/12/2023Thursday152
01/13/2023Friday152
01/14/2023Saturday052
01/15/2023Sunday052
01/16/2023Monday153
01/17/2023Tuesday153
01/18/2023Wednesday153
01/19/2023Thursday153
01/20/2023Friday153
01/21/2023Saturday053
01/22/2023Sunday053
01/23/2023Monday154
01/24/2023Tuesday154
01/25/2023Wednesday154
01/26/2023Thursday154
01/27/2023Friday154
01/28/2023Saturday054
01/29/2023Sunday054
2 ACCEPTED SOLUTIONS
FreemanZ
Super User
Super User

hi @BODMON 

not sure if i fully get you, adding additional column to a matrix might not be easy, you may try to add new table or matrix visual, like this:

FreemanZ_0-1676792377268.png

 

the code for the two measures:

Daily Avg CW = 
VAR _workingdays =
COUNTROWS(
    FILTER(
        Dates,
        Dates[Business_Day]=1
    )
)
RETURN
DIVIDE(
    SUM(TableName[Tickets]),
    _workingdays
)

Daily Avg LW = 
CALCULATE(
    [Daily Avg CW],
    DATEADD(Dates[Date], -7, DAY)
)

 

in the second table visual, there are actually three fields: user column and the two measures. 

FreemanZ_1-1676792511470.png

 

View solution in original post

Crazy. Figured it out.

 

The original source data for the ticket table has a date with a time stamp on it.

 

So even though its format was date and I convert it to short date in PowerBI, it still has an impact. It was not liking the relationship between the ticket table and the date table.

 

I had to go to the source in SQL and convert it there so it would come through just as a date.

 

Very annoying when something so small takes so long to troubleshoot.

 

Thank you for your help @FreemanZ , the weekly averages work!!

 

 

Now I need to see how I can put those weekly average columns into one matrix table, rather than 2 matrix tables…reading @Greg_Deckler 

post and it seems like it’s going to be fun 🙂

View solution in original post

6 REPLIES 6
FreemanZ
Super User
Super User

hi @BODMON 

not sure if i fully get you, adding additional column to a matrix might not be easy, you may try to add new table or matrix visual, like this:

FreemanZ_0-1676792377268.png

 

the code for the two measures:

Daily Avg CW = 
VAR _workingdays =
COUNTROWS(
    FILTER(
        Dates,
        Dates[Business_Day]=1
    )
)
RETURN
DIVIDE(
    SUM(TableName[Tickets]),
    _workingdays
)

Daily Avg LW = 
CALCULATE(
    [Daily Avg CW],
    DATEADD(Dates[Date], -7, DAY)
)

 

in the second table visual, there are actually three fields: user column and the two measures. 

FreemanZ_1-1676792511470.png

 

Hi @FreemanZ !

 

Thanks for your reply!

 

I tried your method and it seems to fix part of it. It seems like the measures you suggested only work with the date in the dates table. 

 

 

My issue is now with the dates. Which date did you use for the date slicer? The one from the ticket table or the dates table?

 

Did you create a relationship between them? I tried to and it didn't work for some reason so I deleted the relationship. 

 

 

I would need one date filter to be able to control all. 

 

Here's a link to the pbix file: Sample PowerBI.pbix

 

Thanks!

hi @BODMON 

the slicer is fed by the dates table. the dates table is linked with the ticket table.

 

as [Daily Avg LW] refers to 7 days before the sliced range, so try either delete the 2nd slicer or extend  to cover the last week. 

FreemanZ_0-1676862342867.png

 

As a general rule, try always use the field from the dimensional table, like dates in this case. 

 

Crazy. Figured it out.

 

The original source data for the ticket table has a date with a time stamp on it.

 

So even though its format was date and I convert it to short date in PowerBI, it still has an impact. It was not liking the relationship between the ticket table and the date table.

 

I had to go to the source in SQL and convert it there so it would come through just as a date.

 

Very annoying when something so small takes so long to troubleshoot.

 

Thank you for your help @FreemanZ , the weekly averages work!!

 

 

Now I need to see how I can put those weekly average columns into one matrix table, rather than 2 matrix tables…reading @Greg_Deckler 

post and it seems like it’s going to be fun 🙂

Greg_Deckler
Community Champion
Community Champion

@BODMON So like this?

Daily Average = 
    VAR __Days = ( MAX('Dates'[Date]) - MIN('Dates'[Date]) ) * 1.
    VAR __Tickets = SUM('Table'[Tickets])
    VAR __Result = DIVIDE(__Tickets, __Days, 0)
RETURN
    __Result

Also, you'll likely want this: The New Hotness (Custom Matrix Hierarchy) - Microsoft Power BI Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Thank you for your reply! I read your post before I posted on How To Get Your Question Answered Quickly  so hopefully I did an OK job 🙂  

 

 

I created a Column: 

 

WeeklyBusinessDays =
VAR VarDate = DATE(2023,01,16)
VAR MaxDate = DATE(2023,01,20)
RETURN
if ( Dates[Date] <= MaxDate,
CALCULATE (
SUM(Dates[Business_Day]),
FILTER (
Dates,
Dates[Date] >= VarDate && Dates[Date] <= MaxDate)
)
, 0)

 

So this would return 5 days which is correct. Problem is it's not dynamic because all I did was enter in a fixed date for both Variables. I'd need it to calculate how many business days between the first day of the week (Monday) and the last day of the week (Friday).

In an ideal world it wouldn't even just be limited to only a week, but more of a filter that could adjust the date range and calculate the amount of busines days between the start and end date selected. But i'd settle for it always being a week. Any thoughts?

 

 

Then I created a measure:

DailyAverage = SUM('Table'[Tickets])/MAX(Dates[WeeklyBusinessDays])

This gives me the correct result. However to throw that in a matrix table as a value seems to make the Matrix goes crazy, as you pointed out in your "The New Hotness" post.

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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