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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Human
Frequent Visitor

Help with volume used for the day

Hi, I want to create a calculated column where it could calculate the usage of the volume for the day. I was hoping that it could subtract the volume reading from the start of the day with the end of the day at a specific time (06:30:00 at the morning and 11:30:00 at night) and display the result in the calculated column.

 

Human_0-1697104449081.png

The volume used per day is the column that I am aiming to create. Please help..

1 ACCEPTED SOLUTION
some_bih
Super User
Super User

Hi @Human possible solution: create calculated column as request like below, adjust Sheet1 to your table name

 

Volume used per day =
VAR __current_time = Sheet1[timestamp ]
VAR __start_of_day =
    DATE ( YEAR ( Sheet1[timestamp ] ), MONTH ( Sheet1[timestamp ] ), DAY ( Sheet1[timestamp ] ) )
        + TIME ( 6, 30, 0 )
VAR __end_of_day =
    DATE ( YEAR ( Sheet1[timestamp ] ), MONTH ( Sheet1[timestamp ] ), DAY ( Sheet1[timestamp ] ) )
        + TIME ( 23, 30, 0 )
VAR __volume_start_day =
    CALCULATE (
        SUM ( Sheet1[Volume] ),
        FILTER ( ALL ( Sheet1 ), Sheet1[timestamp ] = __start_of_day )
    )
VAR __volume_end_day =
    CALCULATE (
        SUM ( Sheet1[Volume] ),
        FILTER ( ALL ( Sheet1 ), Sheet1[timestamp ] = __end_of_day )
    )
RETURN
    IF ( __current_time = __end_of_day, __volume_start_day - __volume_end_day, 0 )
 

Did I answer your question? Kudos appreciated / accept solution!

some_bih_0-1697113546918.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






View solution in original post

2 REPLIES 2
some_bih
Super User
Super User

Hi @Human possible solution: create calculated column as request like below, adjust Sheet1 to your table name

 

Volume used per day =
VAR __current_time = Sheet1[timestamp ]
VAR __start_of_day =
    DATE ( YEAR ( Sheet1[timestamp ] ), MONTH ( Sheet1[timestamp ] ), DAY ( Sheet1[timestamp ] ) )
        + TIME ( 6, 30, 0 )
VAR __end_of_day =
    DATE ( YEAR ( Sheet1[timestamp ] ), MONTH ( Sheet1[timestamp ] ), DAY ( Sheet1[timestamp ] ) )
        + TIME ( 23, 30, 0 )
VAR __volume_start_day =
    CALCULATE (
        SUM ( Sheet1[Volume] ),
        FILTER ( ALL ( Sheet1 ), Sheet1[timestamp ] = __start_of_day )
    )
VAR __volume_end_day =
    CALCULATE (
        SUM ( Sheet1[Volume] ),
        FILTER ( ALL ( Sheet1 ), Sheet1[timestamp ] = __end_of_day )
    )
RETURN
    IF ( __current_time = __end_of_day, __volume_start_day - __volume_end_day, 0 )
 

Did I answer your question? Kudos appreciated / accept solution!

some_bih_0-1697113546918.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Thank you very much @some_bih !!.. this is exactly the solution that I've been aiming..

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

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