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

## Calculate Sum with Filter is almost doubling results

Using the below table I am trying to calculate a filed to refelct the privious recorded value with the restrictions set by the filter. For some reson the value that returns is basically double what I expect.

Previous Meter kwh = CALCULATE(

SUM('TEST Electric Meters Summerized'[Meter kwh]),

FILTER(

'TEST Electric Meters Summerized',

'TEST Electric Meters Summerized'[Attribute]=EARLIER('TEST Electric Meters Summerized'[Attribute])

&&'TEST Electric Meters Summerized'[Datetime Prior]<EARLIER('TEST Electric Meters Summerized'[DataTimestamp])

&&'TEST Electric Meters Summerized'[DataTimestamp] >= EARLIER('TEST Electric Meters Summerized'[Datetime Prior])))

Datetime Prior =
CALCULATE(MAX('TEST Electric Meters Summerized'[DataTimestamp]),

FILTER(
'TEST Electric Meters Summerized',
'TEST Electric Meters Summerized'[DataTimestamp] < EARLIER('TEST Electric Meters Summerized'[DataTimestamp])))

Community Support

Hi @JLET ,

In the filters, 'TEST Electric Meters Summerized'[Attribute]=EARLIER('TEST Electric Meters Summerized'[Attribute]) is grouped according to Attribute.

What do below two filters do?

&&'TEST Electric Meters Summerized'[Datetime Prior]<EARLIER('TEST Electric Meters Summerized'[DataTimestamp])
&&'TEST Electric Meters Summerized'[DataTimestamp] >= EARLIER('TEST Electric Meters Summerized'[Datetime Prior])))

And if there's no order internally for records in table when you want to get previous row. You have to add an index column in your table. Please refer to

Solved: How to get previous row value for text column. - Microsoft Power BI Community

Best Regards,

Stephen Tao

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