Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
I am having a table where there are duplication of column code and its corresponding productioncount . So I wrote the DAX to take average of production of each code and sum it up to get the total production of day.
NTest =
var x = SUMX(SUMMARIZE(WASTAGE,(WASTAGE[CODE]), "SUMM", sum(WASTAGE[PRODUCTION])), [SUMM])
var y = count(WASTAGE[PRODUCTION])
return
x/y
NTest1 =
VAR a = VALUES(WASTAGE[CODE] )
VAR Result = SUMX(a,[NTest])
RETURN
IF(HASONEFILTER(WASTAGE[CODE]), [NTest], Result)
Now I need to calculate MTD and YTD using the same logic i.e, when i select a date, it needs to find the average production of each code, sum it up for all the days till the date selected. Any help is appreciated.
Solved! Go to Solution.
Hi @Anonymous ,
Here some steps that I want to share, you can check them if they suitable for your requirement.
Here is my test data:
MTD
MTD Average Production =
VAR SelectedDate = MAX(WASTAGE[Date])
VAR MTDRange = DATESMTD(WASTAGE[Date])
RETURN
CALCULATE(
[NTest1],
MTDRange,
FILTER(ALLSELECTED(WASTAGE), WASTAGE[Date] <= SelectedDate)
)
YTD
YTD Average Production =
VAR SelectedDate = MAX(WASTAGE[Date])
VAR YTDRange = DATESYTD(WASTAGE[Date])
RETURN
CALCULATE(
[NTest1],
YTDRange,
FILTER(ALLSELECTED(WASTAGE), WASTAGE[Date] <= SelectedDate)
)
Final output
Best regards
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @Anonymous ,
Here some steps that I want to share, you can check them if they suitable for your requirement.
Here is my test data:
MTD
MTD Average Production =
VAR SelectedDate = MAX(WASTAGE[Date])
VAR MTDRange = DATESMTD(WASTAGE[Date])
RETURN
CALCULATE(
[NTest1],
MTDRange,
FILTER(ALLSELECTED(WASTAGE), WASTAGE[Date] <= SelectedDate)
)
YTD
YTD Average Production =
VAR SelectedDate = MAX(WASTAGE[Date])
VAR YTDRange = DATESYTD(WASTAGE[Date])
RETURN
CALCULATE(
[NTest1],
YTDRange,
FILTER(ALLSELECTED(WASTAGE), WASTAGE[Date] <= SelectedDate)
)
Final output
Best regards
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.