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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Calculate average of sum of production for each code

Hi,
I am having a date filter with values year, month and day. I am having a table with two columns - one with code (it has duplicates) and corresponding productions for the day selected. I tried the following measure but its wrong. 

 

CALCULATE(SUMX(VALUES('WASTAGE'[CODE]), AVERAGE('WASTAGE'[PRODUCTION])))

 

Can anyone help ?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi , I found a working solution to the above problem. Im adding it here just for reference.

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)

View solution in original post

3 REPLIES 3
qqqqqwwwweeerrr
Super User
Super User

Hi @Anonymous 

 

Can you provide more details about the data and expected output? Sample data. The problem statement is not very clear.

 

Regads

Anonymous
Not applicable

Hi @qqqqqwwwweeerrr , thanks for your response. 

ann_2024_0-1707076499049.png

Iam having a date filter. On selecting the date I want (4th-jan-2023 here) i want to calculate the total sum of averages of the production wrt to the code i.e ((800+800+.....+800)/7) + ((11776+ 11776+ .....11776)/5) => 800+11776 = 12567

I have tried the following measure , 

 

 

Total_production = SUMX(VALUES('WASTAGE'[CODE]), AVERAGE('WASTAGE'[PRODUCTION]))

 

 

and im getting 10,746 as the result for the above data which is wrong. Any help is appreciated.
Thanks.

Anonymous
Not applicable

Hi , I found a working solution to the above problem. Im adding it here just for reference.

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)

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.