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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Why averagex not showing the correct result

Hi all,

 

Averagex formula :

 

UniqueTarget = AVERAGEX(DISTINCT(SAP_PPT_EV_MaterialDocument_TotalGR[Target]),SAP_PPT_EV_MaterialDocument_TotalGR[Target])
 

Why when I used above formula for average, I got the incorrect result 96.13%. It should be 96.06% when I try to average it in excel.

 

PD4640WASHI640 CH Machine94.000%
PD4640WASHI640 CD Machine94.000%
PD4640WASHI640 CK Machine94.000%
PD4640WASHI640 CG Machine94.000%
PD4640WASHI640 CC Machine94.000%
PD4640EM DC/T640 CB Machine96.900%
PD4640EM DC/T640 CC Machine96.900%
PD4640DC/T640 CB Machine97.500%
PD4640DC/T640 CC Machine97.500%
PD4640EPM Polyester640 CC Machine97.500%
PD4640SPV640 CB Machine97.500%
PD4640TAPE640 CC Machine97.500%
PD4640TAPE640 CD Machine97.500%
PD4400EM DC/T400 WH Machine96.000%
PD4400DC/T400 WH Machine96.000%
PD4400WASHI400 WK Machine94.000%

 

Regards,

Nuha

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

 

Thanks for the reply from @vicky_ .

 

The AVERAGEX function in Power BI calculates the average of the expressions computed for each row in a table. When you use the DISTINCT function in AVERAGEX, DISTINCT removes duplicate values from the data set before performing the average calculation. This may be the reason you are observing differences.

 

I did the calculations using the example data you provided and looked at your latest reply and calculated the correct results in your reply.

 

Please try.

 

Create a measure:

 

Measure = 
VAR _count = CALCULATE(COUNTROWS('Table'),ALL('Table'))
VAR _sum = CALCULATE(SUM('Table'[Value]),ALL('Table'))
RETURN
DIVIDE(_sum,_count)

 

 

After creating a good drag it to the table visual object, you may see the results displayed as 1, do not panic, set its format as a percentage and then select the number of decimal places you want to retain can be.

vhuijieymsft_0-1716860575727.png

 

This was successful and the page visualization is shown below:

vhuijieymsft_1-1716860575731.png

 

The pbix file is attached.

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Anonymous
Not applicable

Hi @Anonymous,

 

I already try your formula but it give me the wrong value

 

nuhasan_1-1716940605861.png

 

 

nuhasan_0-1716940572948.png

 

Regards,

Nuha

 

vicky_
Super User
Super User

I tried having a go with your data, but couldn't match your results exactly. Since there are no headers provided, I assume that the last column in your data is the target. 

vicky__2-1716790190221.png

I'm assuming you want the equivalent target value in cell E18 shown above. Note how it is different from the average value shown in cell H6, despite both of them being averages. If your target value is NOT a measure / is not summarized or aggregated, you can use the AVERAGE function (without the X) and that should give you the correct values.

 

Otherwise, your current measure is grabbing each of the unique target values in E2:E17, (i.e the values in H2:H5), and then taking the average value to get the result of 96.1% in the spreadsheet above. To fix it, you can try something like the below:

New Measure = 
var summaryTable = ADDCOLUMNS(SUMMARIZE(TableName, [ColumnB], [ColumnC], [ColumnD]), "target", [Your Target Measure])
RETURN AVERAGEX(summaryTable, [Your Target Measure])

The idea is that you create a virtual table which matches the data that you're seeing, and then you iterate over each of the rows in that virutal table to get your average.

 

Anonymous
Not applicable

Hi @vicky_ ,

 

Thank you for your solution but it still do not give me the correct answer. As you can see below I filter 2 different month and the result is different because not all month have all machine running. The correct answer should be 95.93%.

 

Any formulation that it will not effect the number of machine running or etc?

 

 

 

nuhasan_2-1716791955504.png

nuhasan_3-1716791974289.png

 

Regards,

Nuha

 

 

 

 

 

 

 

Regards,

Nuha

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors