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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
lamlamm24
Helper I
Helper I

Average Number of Sessions for the past 6 weeks in a selected Day of Week

Please I need help. 
I have a DAX measure that shows the Total Sessions Completed in my report. 
I want to write a DAX to show the Average Number of Sessions for the past 6 weeks. 
I need the DAX to meet the following conditions. 

1. If I select any day of the week e.g Monday. 
I would want the DAX measure to calculate the average number of sessions completed for the past 6 Monday. 
if the selected day is a Tuesday, I want the DAX to calculate the average number of sessions completed for the past 6 Tuesdays. 

so whatever DAY I select on my date filter I want to see the average number of sessions completed for the selected day.

 

1 ACCEPTED SOLUTION
v-yaningy-msft
Community Support
Community Support

Hi, @lamlamm24 

Thanks for @PhilipTreacy reply. You can refer to the following measures.

vyaningymsft_0-1714457498726.png

vyaningymsft_1-1714457514266.png

Measures:

DateWeekDay =
VAR _date_date =
    SELECTEDVALUE ( 'Date'[Date] )
VAR _weekDay =
    WEEKDAY ( _date_date, 2 )
RETURN
    _weekDay


TableWeekDay =
VAR _table_date =
    SELECTEDVALUE ( 'Table'[Date] )
VAR _date_date =
    SELECTEDVALUE ( 'Date'[Date] )
VAR _table_status =
    SELECTEDVALUE ( 'Table'[status] )
VAR _weekday =
    WEEKDAY ( _table_date, 2 )
VAR _isSameWeekday =
    IF ( _weekday = [DateWeekDay], 1, 0 )
VAR _isInSixWeeks =
    IF ( _table_date < _date_date && _table_date >= _date_date - 42, 1, 0 )
VAR _filterDate =
    IF ( _table_status = "Completed" && _isSameWeekday && _isInSixWeeks, 1, 0 )
RETURN
    _filterDate


Previous Six Weeks Completed Counts =
CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( 'Table', [TableWeekDay] = 1 ) )


 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

2 REPLIES 2
v-yaningy-msft
Community Support
Community Support

Hi, @lamlamm24 

Thanks for @PhilipTreacy reply. You can refer to the following measures.

vyaningymsft_0-1714457498726.png

vyaningymsft_1-1714457514266.png

Measures:

DateWeekDay =
VAR _date_date =
    SELECTEDVALUE ( 'Date'[Date] )
VAR _weekDay =
    WEEKDAY ( _date_date, 2 )
RETURN
    _weekDay


TableWeekDay =
VAR _table_date =
    SELECTEDVALUE ( 'Table'[Date] )
VAR _date_date =
    SELECTEDVALUE ( 'Date'[Date] )
VAR _table_status =
    SELECTEDVALUE ( 'Table'[status] )
VAR _weekday =
    WEEKDAY ( _table_date, 2 )
VAR _isSameWeekday =
    IF ( _weekday = [DateWeekDay], 1, 0 )
VAR _isInSixWeeks =
    IF ( _table_date < _date_date && _table_date >= _date_date - 42, 1, 0 )
VAR _filterDate =
    IF ( _table_status = "Completed" && _isSameWeekday && _isInSixWeeks, 1, 0 )
RETURN
    _filterDate


Previous Six Weeks Completed Counts =
CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( 'Table', [TableWeekDay] = 1 ) )


 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

PhilipTreacy
Super User
Super User

Hi @lamlamm24 

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

 

Please supply some data we can work with, files or text, not pictures.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.