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

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.

Reply
ausphil
Helper I
Helper I

Hourly difference between cumulative total

Hello,

 

I have a table that has person, time of reading, and total steps reading from their pedometer. The data syncs every hour. I would like to create a calculated column (Hourly Steps) that returns the difference between the total steps reading for each hour. Appreciate any assistance, thanks!

 

PersonSyncTimeTotal Steps Hourly Steps
John12-09-18 7:0020000  
Martin12-09-18 9:00599  
James12-09-18 6:00125  
James12-09-18 7:00472 347
John12-09-18 8:0020120 120
Martin12-09-18 10:00752 

153

1 ACCEPTED SOLUTION
balaganeshv2201
Frequent Visitor

Hourly Steps = if(ISBLANK(CALCULATE(SUM([Total Steps]),FILTER(Table1,Table1[Person]=EARLIER(Table1[Person])&& Table1[SyncTime]<EARLIER(Table1[SyncTime])))) ,BLANK(), [Total Steps]- CALCULATE(max([Total Steps]),FILTER(Table1,Table1[Person]=EARLIER(Table1[Person])&& Table1[SyncTime]<EARLIER(Table1[SyncTime]))))

------------------

try this

View solution in original post

7 REPLIES 7
balaganeshv2201
Frequent Visitor

Hourly Steps = if(ISBLANK(CALCULATE(SUM([Total Steps]),FILTER(Table1,Table1[Person]=EARLIER(Table1[Person])&& Table1[SyncTime]<EARLIER(Table1[SyncTime])))) ,BLANK(), [Total Steps]- CALCULATE(max([Total Steps]),FILTER(Table1,Table1[Person]=EARLIER(Table1[Person])&& Table1[SyncTime]<EARLIER(Table1[SyncTime]))))

------------------

try this


@balaganeshv2201 wrote:

Hourly Steps = if(ISBLANK(CALCULATE(SUM([Total Steps]),FILTER(Table1,Table1[Person]=EARLIER(Table1[Person])&& Table1[SyncTime]<EARLIER(Table1[SyncTime])))) ,BLANK(), [Total Steps]- CALCULATE(max([Total Steps]),FILTER(Table1,Table1[Person]=EARLIER(Table1[Person])&& Table1[SyncTime]<EARLIER(Table1[SyncTime]))))

------------------

try this



Thank you sir, this worked!

Ashish_Mathur
Super User
Super User

Hi,

 

Try this calculated column formula

 

=if(ISBLANK(CALCULATE(SUM([Total Steps]),FILTER(Table1,Table1[Person]=EARLIER(Table1[Person])&&Table1[SyncTime]<EARLIER(Table1[SyncTime])))),BLANK(),[Total Steps]-CALCULATE(SUM([Total Steps]),FILTER(Table1,Table1[Person]=EARLIER(Table1[Person])&&Table1[SyncTime]<EARLIER(Table1[SyncTime]))))

 

Hope this helps.

 

Untitled.png


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

Hi Ashish,

 

Thanks for providing that formula. It works for when there are only 2 synctimes but once you get to 3 synctimes, it will subtract all the previous synctime total steps too.

 

 

Hi,

 

Try this

 

=if(ISBLANK(CALCULATE(SUM([Total Steps]),FILTER(Table1,Table1[Person]=EARLIER(Table1[Person])&&Table1[SyncTime]<EARLIER(Table1[SyncTime])))),BLANK(),[Total Steps]-LOOKUPVALUE([Total Steps],[Person],[Person],[SyncTime],CALCULATE(MAX([Synctime]),FILTER(Table1,Table1[Person]=EARLIER(Table1[Person])&&Table1[SyncTime]<EARLIER(Table1[SyncTime]))))


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


@Ashish_Mathur wrote:

Hi,

 

Try this

 

=if(ISBLANK(CALCULATE(SUM([Total Steps]),FILTER(Table1,Table1[Person]=EARLIER(Table1[Person])&&Table1[SyncTime]<EARLIER(Table1[SyncTime])))),BLANK(),[Total Steps]-LOOKUPVALUE([Total Steps],[Person],[Person],[SyncTime],CALCULATE(MAX([Synctime]),FILTER(Table1,Table1[Person]=EARLIER(Table1[Person])&&Table1[SyncTime]<EARLIER(Table1[SyncTime]))))


Hi Ashish thanks for the updated formula. I tested the previous respondent's and that worked so I stuck with that.

Hi,

 

I do not understand.  My formula will deduct the total steps appeaing against the sync time just prior to the sync time of the current row from the total steps of the current row.


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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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