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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

@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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

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]))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.