cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

New Member

## averageX with where statement?

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
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)

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.

2 REPLIES 2
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)

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.

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

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.