This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
I’m having trouble creating measures in Power BI to calculate an average per working day for specific quantities.
Date table (Date)
Quantity table (Plant, Group, Quantity, Date, Key_Plant_Year_Month)
Working days table (Plant, Year, Month, WorkingDays, Key_Plant_Year_Month)
| Plant | Year | Month | WorkingDays |
| 1 | 2024 | 1 | 22 |
| 3 | 2024 | 1 | 23 |
| 1 | 2024 | 2 | 24 |
| 3 | 2024 | 2 | 23 |
| Month | 1 | 2 | ||
| Year | 2024 | 2024 | ||
| Plant | Quantity | Avg per Working day | Quantity | Avg per Working day |
| 1 | 66000 (22 WD) | 3000 | 48000 (24 WD) | 2000 |
| 3 | 46000 (23 WD) | 2000 | 69000 (23 WD) | 3000 |
| Sum | 112000 | 5000 | 117000 | 5000 |
I am able to get these correct values and sum with these two Measures:
I need to use sumx in the second meassure to not mess up with the working days, which cannot be summed up right?
| Month | 1 | 2 | ||
| Year | 2024 | 2024 | ||
| Plant | Quantity | Avg per Working day | Quantity | Avg per Working day |
| 1 | 66000 (22 WD) | 3000 | 114000 (46 WD) | 2478,26 |
| 3 | 46000 (23 WD) | 2000 | 115000 (46 WD) | 2500 |
| Sum | 112000 | 5000 | 117000 | 4978,26 |
Solved! Go to Solution.
Your YTD numbers are the sum of per-plant YTD ratios, not the total YTD quantity divided by the total YTD working days. To get that pattern, iterate explicitly over plants and compute the ratio inside each iteration. Try:
Avg per Working day YTD =
SUMX (
VALUES ( 'Quantity table'[Plant] ),
CALCULATE (
DIVIDE (
SUM ( 'Quantity table'[Quantity] ),
SUM ( 'Working days table'[WorkingDays] )
),
DATESYTD ( 'Date'[Date] )
)
)For Plant 1 in Feb 2024 this returns (66000+48000)/(22+24) = 2478.26, and the cross-plant Sum becomes 2478.26 + 2500 = 4978.26, matching the table you posted. You cannot just wrap your existing SUMX(Quantity, [Quantity per WD]) in CALCULATE with DATESYTD, because that iterates daily rows and divides each by its own month's working days, so you end up with the sum of monthly averages instead of the YTD ratio. Make sure the Date table is marked as a date table, so the YTD filter flows through the Date and Key_Plant_Year_Month relationships correctly.
If this works for you, kindly mark it as the solution and give a thumbs up.
Best,
Shai Karmani
Hi,
Please share the download link of the PBI file. Show the problem there very clearly.
Your YTD numbers are the sum of per-plant YTD ratios, not the total YTD quantity divided by the total YTD working days. To get that pattern, iterate explicitly over plants and compute the ratio inside each iteration. Try:
Avg per Working day YTD =
SUMX (
VALUES ( 'Quantity table'[Plant] ),
CALCULATE (
DIVIDE (
SUM ( 'Quantity table'[Quantity] ),
SUM ( 'Working days table'[WorkingDays] )
),
DATESYTD ( 'Date'[Date] )
)
)For Plant 1 in Feb 2024 this returns (66000+48000)/(22+24) = 2478.26, and the cross-plant Sum becomes 2478.26 + 2500 = 4978.26, matching the table you posted. You cannot just wrap your existing SUMX(Quantity, [Quantity per WD]) in CALCULATE with DATESYTD, because that iterates daily rows and divides each by its own month's working days, so you end up with the sum of monthly averages instead of the YTD ratio. Make sure the Date table is marked as a date table, so the YTD filter flows through the Date and Key_Plant_Year_Month relationships correctly.
If this works for you, kindly mark it as the solution and give a thumbs up.
Best,
Shai Karmani
@Shai_Karmani Thank you very much!
I found a solution by myself but yours is a lot cleaner. Thanks for the explanation.
Check out the April 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 |
|---|---|
| 37 | |
| 28 | |
| 28 | |
| 19 | |
| 18 |
| User | Count |
|---|---|
| 69 | |
| 38 | |
| 32 | |
| 28 | |
| 24 |