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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
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.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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