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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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!:
The Definitive Guide to Power Query (M)

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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.