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
Anonymous
Not applicable

substraction in previous rows on a current filter

i am trying to subtract previous lines to get the number of seconds of two times. i always need the calculation for my selected filter as my data set is too large and an error message comes up. i always need the calculation of times for my selected view based on the filters not for the complete file.  

 

mo12_0-1679575241949.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous ,

 

Here are the steps you can follow:

1. Create measure.

Measure =
var _last=
MAXX(
    FILTER(ALLSELECTED('Table'),
    'Table'[Date1]<MAX('Table'[Date1])),[Date1])
return
DATEDIFF(
    _last,MAX('Table'[Date1]),SECOND)

2. Result:

Before filtering:

vyangliumsft_0-1679883836828.png

 

After filtering:

vyangliumsft_1-1679883836830.png

 

Best Regards,

Liu Yang

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi  @Anonymous ,

 

Here are the steps you can follow:

1. Create measure.

Measure =
var _last=
MAXX(
    FILTER(ALLSELECTED('Table'),
    'Table'[Date1]<MAX('Table'[Date1])),[Date1])
return
DATEDIFF(
    _last,MAX('Table'[Date1]),SECOND)

2. Result:

Before filtering:

vyangliumsft_0-1679883836828.png

 

After filtering:

vyangliumsft_1-1679883836830.png

 

Best Regards,

Liu Yang

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

Anonymous
Not applicable

can you tell me also how i can calculate the average time of the row?

 

thank you for your help

lbendlin
Super User
Super User

You would use the OFFSET function for that. Give it a try.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.