Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi!
I have an electricity meter that is measuring cumulatively but I need to calculate the difference, therefore, the electricity use each hour. All the electricity data is in one column and I need to, for example, calculate the difference between Row 2-Row 1 for all of the rows. Is there a way to do this in Power BI?
Many thanks for any help you can give me!
Solved! Go to Solution.
Hi @Anonymous,
Take below simple data as an example.
To get the difference between rows via calculated column.
diff = Table3[Value] - CALCULATE ( SUM ( Table3[Value] ), FILTER ( Table3, Table3[Index] = EARLIER ( Table3[Index] ) - 1 ) )
To get difference between rows via measure.
diff measure = SELECTEDVALUE ( Table3[Value] ) - CALCULATE ( SUM ( Table3[Value] ), FILTER ( ALLSELECTED ( Table3 ), Table3[Index] = SELECTEDVALUE ( Table3[Index] ) - 1 ) )
For more advice, please provide your sample data and desired output. How to Get Your Question Answered Quickly
Best regards,
Yuliana Gu
Hi @Anonymous,
Take below simple data as an example.
To get the difference between rows via calculated column.
diff = Table3[Value] - CALCULATE ( SUM ( Table3[Value] ), FILTER ( Table3, Table3[Index] = EARLIER ( Table3[Index] ) - 1 ) )
To get difference between rows via measure.
diff measure = SELECTEDVALUE ( Table3[Value] ) - CALCULATE ( SUM ( Table3[Value] ), FILTER ( ALLSELECTED ( Table3 ), Table3[Index] = SELECTEDVALUE ( Table3[Index] ) - 1 ) )
For more advice, please provide your sample data and desired output. How to Get Your Question Answered Quickly
Best regards,
Yuliana Gu
Hi, I tried this and getting error message...
MdxScript(Model) (12,162) Calculation error in measure
Hi Yuliana,
If i want to make Row 1 - Row 2 to get the difference, how should the measure look like?
Thank you in advance
See my article on Mean Time Before Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |