The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello All
Below is what I am trying to achieve in Power BI:
In essence I need to be able to create a daily rolling average which resets at the beginning of each new month....
Thanks in advance!
Solved! Go to Solution.
@kc_ ,Create a new calculated column using below measure
Proud to be a Super User! |
|
Hi @kc_
Are you usinga date table in your model? Then this will help
Avg. Jobs Per Day =
VAR LastCurrentDate =
MAX ( 'DIM Date'[Date] )
VAR Period =
DATESBETWEEN ( 'DIM Date'[Date], EOMONTH(LastCurrentDate, -1) + 1, LastCurrentDate)
VAR TotalJobs =
CALCULATE (
SUM(Jobs[Jobs Completed per Day]),
Period
)
VAR NumOfDays =
COUNTROWS(Period)
VAR Result =
DIVIDE(TotalJobs, NumOfDays)
RETURN
Result
Joe
Proud to be a Super User! | |
Date tables help! Learn more
Hi @kc_
Are you usinga date table in your model? Then this will help
Avg. Jobs Per Day =
VAR LastCurrentDate =
MAX ( 'DIM Date'[Date] )
VAR Period =
DATESBETWEEN ( 'DIM Date'[Date], EOMONTH(LastCurrentDate, -1) + 1, LastCurrentDate)
VAR TotalJobs =
CALCULATE (
SUM(Jobs[Jobs Completed per Day]),
Period
)
VAR NumOfDays =
COUNTROWS(Period)
VAR Result =
DIVIDE(TotalJobs, NumOfDays)
RETURN
Result
Joe
Proud to be a Super User! | |
Date tables help! Learn more
@Joe_Barry hoping you can provide some further assistance...
As mentioned before the DAX you provided works, see table below:
However, for each date is a working day allocated to it (within the data set) and when I incorporate this within the table the following occurs:
In essence I am looking to achieve something similar to the below:
Are you able to assist....
Many thanks
Hi @kc_
Please try for no Staurdays or Sundays
Avg. Jobs Per Day No Weekends =
VAR LastCurrentDate =
MAX ( 'DIM Date'[Date] )
VAR Period =
DATESBETWEEN ( 'DIM Date'[Date], EOMONTH(LastCurrentDate, -1) + 1, LastCurrentDate)
VAR WeekdaysPeriod =
FILTER (
Period,
WEEKDAY ( 'DIM Date'[Date], 2 ) < 6
)
VAR TotalJobs =
CALCULATE (
SUM(Jobs[Jobs Completed per Day]),
WeekdaysPeriod
)
VAR NumOfDays =
COUNTROWS(WeekdaysPeriod)
VAR Result =
DIVIDE(TotalJobs, NumOfDays)
RETURN
Result
This one will exclude days where no Jobs happen
Avg. Jobs Per Day - Leave out non worked days=
VAR LastCurrentDate =
MAX ( 'DIM Date'[Date] )
VAR Period =
DATESBETWEEN ( 'DIM Date'[Date], EOMONTH(LastCurrentDate, -1) + 1, LastCurrentDate)
VAR NonZeroJobsPeriod =
FILTER (
Period,
CALCULATE ( SUM ( Jobs[Jobs Completed per Day] ) ) > 0
)
VAR TotalJobs =
CALCULATE (
SUM(Jobs[Jobs Completed per Day]),
NonZeroJobsPeriod
)
VAR NumOfDays =
COUNTROWS(NonZeroJobsPeriod)
VAR Result =
DIVIDE(TotalJobs, NumOfDays)
RETURN
Result
Joe
Proud to be a Super User! | |
Date tables help! Learn more
Thanks for this @Joe_Barry , however, something is not working for me...perhaps you can send accross your PBIX file instead.
Also, it is critical that the working day numbers are shown as opposed to the actual days of the week since this is what the company reports on.
Below is a screenshot of what I am trying to achieve.
Thanks for this Joe, yes I do have a Date Table, however...see below:
The average jobs per day on 2.01.2024 needs to be 86 and not 43. I only need an average to be calculated if a job has been completed on any given day. Also for context, jobs are only completed Monday to Friday.
The workaround therefore - instead of pointing to the date table, I am pointing to the date completed field of the source data table, in doing so, I am getting the expected figures.
This has worked a treat! Many thanks!!!!
@kc_ ,Create a new calculated column using below measure
Proud to be a Super User! |
|
Thank you!
Thank you Bhanu - however, would you mind re-attaching the PBIX file please...
Check table by going to model not visual
Proud to be a Super User! |
|
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
105 | |
77 | |
74 | |
43 | |
37 |
User | Count |
---|---|
156 | |
109 | |
64 | |
60 | |
55 |