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

Rolling sum of some seconds values

HI,

I am quite new to Power BI. I have a table with2 columns that are times in minutes  as below and a measure "Values" of my items in that specific second. I tried to calculate the rolling sum of the last 5 seconds with this measure 

# Meas =
CALCULATE (
SUM('TT data'[Value]),
FILTER ('TT data',
'TT data'[Time_of_the_Measure] >= MAX ( 'TT data'[Time_of_the_Measure] )
&& 'TT data'[Time_of_the_Measure] <= MAX('TT data'[Time minus 5sec]
)
))

 

but it does not work.

How to do that?



Time_of_the_MeasureTime minus 5sec# Theta# Meas
1899-12-30 12:00:001899-12-30 11:59:55811 
1899-12-30 12:00:011899-12-30 11:59:561509 
1899-12-30 12:00:021899-12-30 11:59:571290 
1899-12-30 12:00:031899-12-30 11:59:581295 
1899-12-30 12:00:041899-12-30 11:59:592409 
1899-12-30 12:00:051899-12-30 12:00:004122 
1899-12-30 12:00:061899-12-30 12:00:014266 
1899-12-30 12:00:071899-12-30 12:00:024637 
1899-12-30 12:00:081899-12-30 12:00:034314 
1899-12-30 12:00:091899-12-30 12:00:044365 
1899-12-30 12:00:101899-12-30 12:00:054131 
1899-12-30 12:00:111899-12-30 12:00:063848 
1899-12-30 12:00:121899-12-30 12:00:073590 
1899-12-30 12:00:131899-12-30 12:00:083527 
1899-12-30 12:00:141899-12-30 12:00:093834 
1899-12-30 12:00:151899-12-30 12:00:103683 
1899-12-30 12:00:161899-12-30 12:00:113639 
1899-12-30 12:00:171899-12-30 12:00:123906 
1 ACCEPTED SOLUTION

Hello @Anonymous 

Use this one.

Measure test = 
CALCULATE (
    SUM ( 'TT data'[# Meas] ),
    FILTER (
        ALL('TT data'[Time_of_the_Measure],'TT data'[Time minus 5sec]),
        'TT data'[Time_of_the_Measure] <= MAX ( 'TT data'[Time_of_the_Measure] )
            && 'TT data'[Time_of_the_Measure] >= MAX ( 'TT data'[Time minus 5sec] )
    )
)

View solution in original post

3 REPLIES 3
jdbuchanan71
Super User
Super User

Hello @Anonymous ,

I think you just had your compare signs flipped so so lines matched.

# Meas =
CALCULATE (
    SUM ( 'TT data'[Value] ),
    FILTER (
        'TT data',
        'TT data'[Time_of_the_Measure] <= MAX ( 'TT data'[Time_of_the_Measure] )
            && 'TT data'[Time_of_the_Measure] >= MAX ( 'TT data'[Time minus 5sec] )
    )
)
Anonymous
Not applicable

hi, it seems it just copies the line

Time_of_the_MeasureTime minus 5sec# Theta# Meas
1899-12-30 12:00:001899-12-30 11:59:55811811
1899-12-30 12:00:011899-12-30 11:59:5615091509
1899-12-30 12:00:021899-12-30 11:59:5712901290
1899-12-30 12:00:031899-12-30 11:59:5812951295
1899-12-30 12:00:041899-12-30 11:59:5924092409
1899-12-30 12:00:051899-12-30 12:00:0041224122
1899-12-30 12:00:061899-12-30 12:00:0142664266
1899-12-30 12:00:071899-12-30 12:00:0246374637
1899-12-30 12:00:081899-12-30 12:00:0343144314
1899-12-30 12:00:091899-12-30 12:00:0443654365
1899-12-30 12:00:101899-12-30 12:00:0541314131
1899-12-30 12:00:111899-12-30 12:00:0638483848
1899-12-30 12:00:121899-12-30 12:00:0735903590
1899-12-30 12:00:131899-12-30 12:00:0835273527
1899-12-30 12:00:141899-12-30 12:00:0938343834
1899-12-30 12:00:151899-12-30 12:00:1036833683
1899-12-30 12:00:161899-12-30 12:00:1136393639
1899-12-30 12:00:171899-12-30 12:00:1239063906
1899-12-30 12:00:181899-12-30 12:00:1338093809

 

I'm using this measure as you suggested. columns are time data type.

# Meas =
CALCULATE (
SUM('TT data'[B: Theta mean (uV) 4-8 Hz]),
FILTER ('TT data',
'TT data'[Time_of_the_Measure] <= MAX ( 'TT data'[Time_of_the_Measure] )
&& 'TT data'[Time_of_the_Measure] >= MAX('TT data'[Time minus 5sec]
)
))
 
BR
Roberto

Hello @Anonymous 

Use this one.

Measure test = 
CALCULATE (
    SUM ( 'TT data'[# Meas] ),
    FILTER (
        ALL('TT data'[Time_of_the_Measure],'TT data'[Time minus 5sec]),
        'TT data'[Time_of_the_Measure] <= MAX ( 'TT data'[Time_of_the_Measure] )
            && 'TT data'[Time_of_the_Measure] >= MAX ( 'TT data'[Time minus 5sec] )
    )
)

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.