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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
dolevh
Helper II
Helper II

Average 4 week same week day

Hi everyone,
I want to produce a function that will make me an average of the number of users each month of all days of the week (Sunday until Saturday)
For example:
The average of Sundays in July is X
The average of Mondays in July is y
The average of Tuesdays in July is Z 

 

Thanks!

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@dolevh So, have to make some assumptions because no sample source data, but perhaps something like:

Measure = 
  VAR __Date = MAX('Table'[Date)
  VAR __Weekday = WEEKDAY(__Date)
  VAR __Month = MONTH(__Date)
  VAR __Year = YEAR(__Date)
  VAR __Table = FILTER(ALL('Table'),[Year]=__Year && [Month]=__Month && [Weekday]=__Weekday)
RETURN
  DIVIDE(
    SUMX(__Table,[Value]),
    COUNTROWS(__Table),
    0
  )


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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Super User
Super User

@dolevh So, have to make some assumptions because no sample source data, but perhaps something like:

Measure = 
  VAR __Date = MAX('Table'[Date)
  VAR __Weekday = WEEKDAY(__Date)
  VAR __Month = MONTH(__Date)
  VAR __Year = YEAR(__Date)
  VAR __Table = FILTER(ALL('Table'),[Year]=__Year && [Month]=__Month && [Weekday]=__Weekday)
RETURN
  DIVIDE(
    SUMX(__Table,[Value]),
    COUNTROWS(__Table),
    0
  )


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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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