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

How to compare LASTDATE's enquiry count to that day's weekday's historical average?

I want to create a daily enquiry report which would provide an enquiry count from the last date’s data in the dataset which is then automatically compared to the historical average of that day’s weekday. So if Power Bi counts enquiries on Wednesday, then the system would automatically calculate the historical enquiry count of Wednesday (average per day count). It would be easy to achieve this goal by using a slicer that has Weekday options on it, but I am wondering whether it would be possible to create a measure which would check the last date’s weekday on the dataset and then calculate that weekday’s average daily enquiry count? 

 

The measure I am using to calculate daily enquiries is as follows:

Enquiries LastDate Count = CALCULATE([Total Enquiries Count],LASTDATE(Enquiries[EnquiryDate]))

I have tried to figure out a solution without a success. I would be grateful if anybody could point me in the right direction.

Here is my example data: 
https://goo.gl/AjLwya

 

 

1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

try this code:

 

Measure = 
VAR TheDate = MAX(Enquiries[EnquiryDate])
VAR DayOfWeek = WEEKDAY(TheDate,2)
VAR SameDays = FILTER(Dates,Dates[WeekDay]=DayOfWeek && Dates[Master Date]<TheDate)
VAR SameDaysEnquires = ADDCOLUMNS(SameDays,"Val",[Total Enquiries Count])
RETURN
AVERAGEX(SameDaysEnquires,[Val])

it calculates the average for all the same days that are before the current date

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

2 REPLIES 2
Stachu
Community Champion
Community Champion

try this code:

 

Measure = 
VAR TheDate = MAX(Enquiries[EnquiryDate])
VAR DayOfWeek = WEEKDAY(TheDate,2)
VAR SameDays = FILTER(Dates,Dates[WeekDay]=DayOfWeek && Dates[Master Date]<TheDate)
VAR SameDaysEnquires = ADDCOLUMNS(SameDays,"Val",[Total Enquiries Count])
RETURN
AVERAGEX(SameDaysEnquires,[Val])

it calculates the average for all the same days that are before the current date

 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Anonymous
Not applicable

Thank you so much, Stachu, for your elegant solution 🙂

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.