This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hi all,
I have a little issue with some average measures and I need urgently help with it.
I need to create MTD and YTD measures which provide me with the average for sales and order sums. The average by then must be filtered by the number of business days. I have some columns in my date table which could be helpful e.g.:
The measures will be displayed on a dashboard with a standard range date slicer. This means, that the users can select any start and end date they like.
By now I tried several simple approaches, e.g.:
Solved! Go to Solution.
Hi @RaMiRo87 ,
You can try formula like below:
M_ =
VAR total_ =
TOTALYTD (
SUM ( 'Table'[Value] ),
'Table'[Date],
FILTER ( 'Table', 'Table'[businessDay] = "Yes" ),
"31/12"
)
VAR count_ =
COUNTROWS (
FILTER (
'Table',
YEAR ( 'Table'[Date] ) = YEAR ( TODAY () )
&& 'Table'[businessDay] = "Yes"
)
)
RETURN
DIVIDE ( total_, count_ )
Best Regards,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @RaMiRo87 ,
You can try formula like below:
M_ =
VAR total_ =
TOTALYTD (
SUM ( 'Table'[Value] ),
'Table'[Date],
FILTER ( 'Table', 'Table'[businessDay] = "Yes" ),
"31/12"
)
VAR count_ =
COUNTROWS (
FILTER (
'Table',
YEAR ( 'Table'[Date] ) = YEAR ( TODAY () )
&& 'Table'[businessDay] = "Yes"
)
)
RETURN
DIVIDE ( total_, count_ )
Best Regards,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you very much!
Looks a lot like my own approach, but yours is working! 😄
Thanks a lot and all the best!
To create MTD (Month-to-Date) and YTD (Year-to-Date) measures for average sales and order sums filtered by the number of business days, you can use the following approach:
1. **MTD Average Measure**:
This measure calculates the average sales or order sums for the month-to-date period, considering only business days.
```DAX
MTD Average =
VAR SelectedStartDate = MIN(dTime[Date])
VAR SelectedEndDate = MAX(dTime[Date])
VAR BusinessDaysInMTD =
CALCULATE(
COUNTROWS(dTime),
dTime[Date] >= DATE(YEAR(SelectedStartDate), MONTH(SelectedStartDate), 1),
dTime[Date] <= SelectedEndDate,
dTime[Business Day (Y/N) EN] = "Yes"
)
RETURN
IF(
ISBLANK(BusinessDaysInMTD),
BLANK(),
AVERAGEX(
FILTER(
fSalesControlling,
fSalesControlling[Date] >= DATE(YEAR(SelectedStartDate), MONTH(SelectedStartDate), 1) &&
fSalesControlling[Date] <= SelectedEndDate
),
fSalesControlling[YourSalesOrOrderMeasure]
) / BusinessDaysInMTD
)
```
2. **YTD Average Measure**:
This measure calculates the average sales or order sums for the year-to-date period, considering only business days.
```DAX
YTD Average =
VAR SelectedStartDate = MIN(dTime[Date])
VAR SelectedEndDate = MAX(dTime[Date])
VAR BusinessDaysInYTD =
CALCULATE(
COUNTROWS(dTime),
YEAR(dTime[Date]) = YEAR(SelectedStartDate),
dTime[Date] <= SelectedEndDate,
dTime[Business Day (Y/N) EN] = "Yes"
)
RETURN
IF(
ISBLANK(BusinessDaysInYTD),
BLANK(),
AVERAGEX(
FILTER(
fSalesControlling,
YEAR(fSalesControlling[Date]) = YEAR(SelectedStartDate) &&
fSalesControlling[Date] <= SelectedEndDate
),
fSalesControlling[YourSalesOrOrderMeasure]
) / BusinessDaysInYTD
)
```
Replace `fSalesControlling` with your sales or order fact table, and `YourSalesOrOrderMeasure` with the appropriate measure column.
These measures calculate the average sales or order sums for the selected MTD or YTD period, considering only the business days within that period. Ensure that your date table (`dTime`) includes the appropriate business day flag column for filtering.
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 27 | |
| 26 | |
| 22 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 42 | |
| 42 | |
| 41 | |
| 21 | |
| 20 |