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
Kolumam
Post Prodigy
Post Prodigy

Calculating the difference in energy readings using difference in dates

Hi All,

 

I have 3 columns. I wanna find the difference between the last and the first readings of "total_energy_generated_till" based on the timestamp of a day and based on the inverter ID. How do I acheive this ?MR Error.JPG

7 REPLIES 7
Ashish_Mathur
Super User
Super User

Hi,

 

Share the PBI file.  Please also show the expected result there.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @Kolumam

 

This calculated table gets pretty close.  Just change where I have 'Table'

 

New Table = SUMMARIZE(
                ADDCOLUMNS(
                    'Table',
                    "Date",DATEVALUE(FORMAT('Table'[Tstamp],"YYYY-MM-DD"))
                    ),
                [Date],
                [InverterID],
                "myMin",MIN('Table'[total_energy_generated_til]),
                "myMax",MAX('Table'[total_energy_generated_til]),
                "Diff",MAX('Table'[total_energy_generated_til]) - MIN('Table'[total_energy_generated_til])
                )

 


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Hi @Phil_Seamark

 

I am using DirectQuery and I am not able to create a new table. Any suggestions please ?

What is your direct query datasource?  Is it an SQL datasource?


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Yes that's right. It is from SQL. I just imported the VIEW from SQL to Power BI. Since I am not good at SQL, I thought of implementing in Power BI. Could you help me ?

HI @Kolumam

 

You can do it easily in Power BI if you weren't using Direct Query.

 

I can help with the T-SQL required to generate a view.  Do you have a screenshot of the SQL Table? (Just the column names)


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Hi @Phil_Seamark

 

Please find my current table in SQL.

SQL.JPG

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.