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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
nicolealexi
New Member

Power BI Iteration Sum based on Consecutive Hours

Hello. I'm trying to write a new column dax to sum a values column based on a four hour consecutive window.  Every 4 hour window would have its own sum. Theoretically, there would be 24 hour rows for each resource on that specific day but I have a limited sample size. For those 24 hours, the date and resource would be the same. For example, on a certain day there would be 24 rows in the hour column for hours 1-24 where the date would read 1/1/2022 and the resource would read 1 for each hour. Resource 1 and 2 would have the same format and for the next day, 1/2/2022. Hours 1-3 would blank since they do not meet the 4 hour consecutive yet. Row 4 of the new column is the value sum of hours 1-4 and the 5th row in the new column is the value sum of hours 2-5. I need a dax formula that would create this sum up until hour 24 which can also be filtered by desired resource or date.

ResourceDateHourValueNew Column
11/1/2022172 

1

1/1/2022231 
11/1/202230.3 
11/1/202240103.3
11/1/202250.231.5
21/1/2022110 
21/1/2022211.2 
21/1/20223-9 
21/1/202241628.2

 

 

1 REPLY 1
Anonymous
Not applicable

Hi  @nicolealexi ,

 

Here are the steps you can follow:

1. Create calculated column.

Falg =
var _count=
COUNTX(
    FILTER(ALL('Table'),'Table'[Resource]=EARLIER('Table'[Resource])),[Hour])
return
IF(
    _count<=3,BLANK(),
    IF(
       [Hour]>3,
        SUMX(
            FILTER(ALL('Table'),            'Table'[Resource]=EARLIER('Table'[Resource])&&'Table'[Hour]>=EARLIER('Table'[Hour])-3&&'Table'[Hour]<=EARLIER('Table'[Hour])),[Value])))

2. Result:

vyangliumsft_0-1688091834494.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

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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