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
Dunner2020
Post Prodigy
Post Prodigy

24 hrs sum column

Hi there,

 

I have a data set that looks like as shown in the picture:

 

leo_89_0-1618195746515.png

In the data EpochHH is the unique number that represents the half-hour time slot of the given date. Now I want to create a new column that calculates the sum of [30 mins value] column in the next 24 hours. The 24-hour window should be floating. So I tried to create a formula that looks like as follow:

 

24 hrs Value = 

CALCULATE(SUMX(FILTER('Fact Table','Fact Table'[EpochHH] >= 'Fact Table'[EpochHH] && 'Fact Table'[EpochHH] <= 'Fact Table'[EpochHH] + 47),'Fact Table'[30 Mins Value]))
 
However, the above formula did not produce the desired result. Could anyone help me where I made the mistake? Sample file can be download from here.

 

1 ACCEPTED SOLUTION

Hi @Dunner2020 ,

 

Please use the following calculated column:

 

24 hrs Value = CALCULATE(SUM('Fact Table'[30 Mins Value]),FILTER('Fact Table','Fact Table'[EpochHH]<=EARLIER('Fact Table'[EpochHH])+47 &&'Fact Table'[EpochHH]>=EARLIER('Fact Table'[EpochHH])))

 

Capture.PNG

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

6 REPLIES 6
Jihwan_Kim
Super User
Super User

Hi, @Dunner2020 

Please try the below.

 

24 hrs Value =
VAR currentHH = 'Fact Table'[EpochHH]
RETURN
SUMX (
FILTER (
'Fact Table',
'Fact Table'[EpochHH] >= currentHH
&& 'Fact Table'[EpochHH] <= currentHH + 47
),
'Fact Table'[30 Mins Value]
)
 
 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

@Jihwan_Kim , thanks for your reply. However, the above-mentioned formula does not produce the desired result as shown in the picture:

leo_89_0-1618260397944.png

The first value shown in 24hrs values column should have been the sum of first two values of 30 Mins values column.

 

Hi @Dunner2020 ,

 

Please use the following calculated column:

 

24 hrs Value = CALCULATE(SUM('Fact Table'[30 Mins Value]),FILTER('Fact Table','Fact Table'[EpochHH]<=EARLIER('Fact Table'[EpochHH])+47 &&'Fact Table'[EpochHH]>=EARLIER('Fact Table'[EpochHH])))

 

Capture.PNG

 

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

 

Best Regards,

Dedmon Dai

Hi, @Dunner2020 

I think you did not use mine. Sorry that I do not know why Calculate is in front of your formula.

Thank you.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
amitchandak
Super User
Super User

@Dunner2020 , Try a new column like

24 hrs Value =
CALCULATE(SUMX(FILTER('Fact Table','Fact Table'[EpochHH] >= earlier('Fact Table'[EpochHH]) && 'Fact Table'[EpochHH] <= earlier('Fact Table'[EpochHH])+ 47),'Fact Table'[30 Mins Value]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak , When I used earlier function it throws an error message that parameter is not correct type as shown in the following picture:

leo_89_0-1618198228747.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.