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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Calculate diff between rows filtering IDs

Hi All,

 

I have a table collecting value each 10 minuts for aprox. 100 different IDs/Tags. 

 

Example of table: 

EnergyTagNoVALUETIMESTAMPConsumption
65128093427-10-2022 11:37 
66418341327-10-2022 11:37 
64246043327-10-2022 11:37 
63545661727-10-2022 11:37 
66418337927-10-2022 11:27 
65128088627-10-2022 11:27 
64246031827-10-2022 11:27 
63545651527-10-2022 11:27 

 

I need a solution that calculates the difference between two timestamps (Based on my date table), and filter on each tag.

I tried following solution: https://community.powerbi.com/t5/Desktop/Subtract-value-from-earlier-rows-depending-on-Category/m-p/...

 

This solution worked as long as I filter out data older than 3 months and narrow down the tags to 4-5. Calculation consumption for a whole year, the report reports and error.

 

Consumption = 
Fact_EnergyData[_VALUE]
    - MAXX(
        TOPN(
            1,
            FILTER(
                Fact_EnergyData,
                Fact_EnergyData[EnergyTagNo] = EARLIER( Fact_EnergyData[EnergyTagNo] )
                    && Fact_EnergyData[_TIMESTAMP] < EARLIER(Fact_EnergyData[_TIMESTAMP] )
            ),
            Fact_EnergyData[_TIMESTAMP]
        ),
        Fact_EnergyData[_VALUE]
    )

 

 Error:

Error.JPG

 

So, my question. Is there any other options to do the calculation? DAX? Power Query? 

 

I look forward to hear from you!

 

Thanks a million in advance.

2 REPLIES 2
v-yadongf-msft
Community Support
Community Support

Hi @Anonymous ,

 

How many records do you get data to Power bi side? How many columns your tables have?


If your tables have too many columns, please try to remove unused columns to increase loading and calculation performances and reduce memory cost.

 

In addition, any nested iterator calculation in your calculated column or measure?

 

They can cause performance issues and spend more memory resources. (e.g. nested three iterators of 1k row tables will multiply the calculation amount to 1k*1k*1k=100m)

 

Best regards,

Yadong Fang

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

Anonymous
Not applicable

Hi @v-yadongf-msft 

 

Thank you for your reply - much appreciated. I will try to answer best possible below:

 

How many records do you get data to Power bi side? How many columns your tables have?

Currently database consist of 8 columns which one is a duplicated column in extract the year, and one is concatenating two columns to create a unique ID. Database has 2 million rows currently and increasing.


If your tables have too many columns, please try to remove unused columns to increase loading and calculation performances and reduce memory cost.


I will try and change how often we log data in the source. Currently it is every 10 minutes. I will change this to every hour. This will in the short run solve the issue. But in the long run I might sooner or later receive the same error. 

 


 

In addition, any nested iterator calculation in your calculated column or measure?

 


I dont have any particular resource consuming measures or calculated columns. 

 

Best regards,

Daniel 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.