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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
fisqkuz
New Member

averageX with where statement?

fisqkuz_0-1647972932898.png

For every hour I want to subtract one column from the other one only if the last column is smaller than the first one. Then I want the average of the result.

 

Currently trying (but failing obviously) like:

 

Avg Spd Column1 =
VAR bigger = SUMX(table1, table1[X] - table1[Y])
VAR two = CALCULATE(SUMX(table1, table1[X] - table1[Y]), bigger > 0)
RETURN
two
1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @fisqkuz 

Try this way, create the measures

DIFF = IF(MIN('Table'[Y])<MIN('Table'[X]),MIN('Table'[X])-MIN('Table'[Y]))
average = AVERAGEX('Table',[DIFF])

result (see sample file attached below)

vxiaotang_0-1648623964258.png

Best Regards,

Community Support Team _Tang

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

View solution in original post

2 REPLIES 2
v-xiaotang
Community Support
Community Support

Hi @fisqkuz 

Try this way, create the measures

DIFF = IF(MIN('Table'[Y])<MIN('Table'[X]),MIN('Table'[X])-MIN('Table'[Y]))
average = AVERAGEX('Table',[DIFF])

result (see sample file attached below)

vxiaotang_0-1648623964258.png

Best Regards,

Community Support Team _Tang

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

amitchandak
Super User
Super User

@fisqkuz , force a  row context/gorup by , prefer visual group/axis/row

 

example time here

 

Avg Spd Column1 =
VAR bigger = CALCULATE(SUMX(table1, table1[X] - table1[Y]))
VAR two = CALCULATE(SUMX(filter(values(table1[Time]),bigger > 0), bigger)
RETURN
two

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.