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

Show average per rows

Hi there,
I have this table and I would like to add column that hold Avg Dist per row based on slicer selection

And add a flag if Dist > Avg then 1 else 0
I couldn't get the average listed per rows

Thanks,

Distance.PNG

2 ACCEPTED SOLUTIONS

@VasTg that's a slightly different issue, the data set posted by the OP did not have any blanks.

 

If you are facing this issue you probably need to explicitly check for blank distances using something like the following.

 

eg.

 Avg Dist = 
IF( NOT( ISBLANK( 'Table'[Distance] ) )
    , CALCULATE(AVERAGE('Table'[Distance]),ALLSELECTED('Table'))
)

 

View solution in original post

Anonymous
Not applicable

Jay,
Thank you for your response, I address the blank issue for calculating Averages from previous comment
Also to work around the total above distance I did
Above Dist = Calculate(
    count(EmpDistance[EmployeeID]),
    filter(EmpDistance, EmpDistance[Distance] > [Average Dist]))
Which gave me the to
Thanks,
OdedDror

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi @Anonymous , @VasTg ,

 

Please refer to the formulas below.

Avg Dist = DIVIDE(SUMX(ALLSELECTED(Table1),Table1[Distance]),COUNTROWS(ALLSELECTED(Table1)))

Dist > Avg = IF(SELECTEDVALUE(Table1[Distance])>[Avg Dist],1,0)

Result would be shown as below.

1.PNG

2.PNG

3.PNG

 

Best Regards,

Jay

Community Support Team _ Jay Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Jay,
Thank you for your response, I address the blank issue for calculating Averages from previous comment
Also to work around the total above distance I did
Above Dist = Calculate(
    count(EmpDistance[EmployeeID]),
    filter(EmpDistance, EmpDistance[Distance] > [Average Dist]))
Which gave me the to
Thanks,
OdedDror

amitchandak
Super User
Super User

Try a measure like

measure =

var _ Avg = calculate(averagex(all(table),distance))

return

calculate(count(emp),distance>_avg)

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube


var _ Avg = calculate(averagex(all(table),distance))

 


The expression above will ignore the slicer selection, but if you change it to the following it should work the way you want

 

var _ Avg = calculate(average('Table'[Distance]), ALLSELECTED('Table'))

@d_gosbell 

 

I tried that option. but it shows all the empID as below.. 

Cap11.PNG

 

 

P.S: I am not the OP.

Connect on LinkedIn

@VasTg that's a slightly different issue, the data set posted by the OP did not have any blanks.

 

If you are facing this issue you probably need to explicitly check for blank distances using something like the following.

 

eg.

 Avg Dist = 
IF( NOT( ISBLANK( 'Table'[Distance] ) )
    , CALCULATE(AVERAGE('Table'[Distance]),ALLSELECTED('Table'))
)

 

Anonymous
Not applicable

Hi there,

I could not bring your IF( NOT( ISBLANK( 'Table'[Distance] ) ) -- It looking for measure

so I did

Average Dist =
Var D = CALCULATE( sum(EmpDistance[Distance]),ALLEXCEPT(EmpDistance,EmpDistance[Job],EmpDistance[PAY_RUN]))
Var E = CALCULATE(
    COUNT(EmpDistance[EmpID]),ALLEXCEPT(EmpDistance,EmpDistance[Job],EmpDistance[PAY_RUN])) - COUNTBLANK(EmpDistance[Distance])
Return DIVIDE(D,E)
And it works

Thanks

Oded Dror

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors