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

Sum between 07 and 07(Today's and Yesterday's)

Hey all,

 

Im trying to sum the values between Today's and yesterday's date between 07:00 and 07:00 (7 am to 7 am).

 

sample data:

DatetimeValue
10/6/2020 6:055610
10/6/2020 8:051103
10/6/2020 9:057313
10/6/2020 10:055961
10/6/2020 11:051798
10/6/2020 12:051849
10/6/2020 13:051231
10/6/2020 14:057773
10/6/2020 15:059199
10/6/2020 16:051439
10/6/2020 17:057551
10/6/2020 18:057546
10/6/2020 19:059752
10/6/2020 20:05438
10/6/2020 21:053461
10/6/2020 22:057773
10/6/2020 23:05761
11/6/2020 0:052809
11/6/2020 7:053666

 

Thanks for your help,

Ariel

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Try this measure 

Measure = 
VAR __end = TODAY() + TIME( 7, 0, 0 )
VAR __start = __end - 1
RETURN 
CALCULATE(
    SUM( 'Table'[Value] ),
    KEEPFILTERS( 
        'Table'[Datetime] >= __start &&
        'Table'[Datetime] < __end
    )
)

 

the result based on your sample will be.

image.png

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn


 

 

View solution in original post

4 REPLIES 4
Hennadii
Helper IV
Helper IV

Hello @Anonymous ,

 

I suggest you to add new Date column to your data table

Date = FORMAT('Time Table'[DateTime], "mm/dd/yyyy")

New Date Column.png

 

 

After that, you can create the following Total measure

Total =
VAR timeSlicer =
    FORMAT ( TIME ( 7, 0, 0 ), "hh:mm:ss" ) //set your time here
VAR currentDay =
    SELECTEDVALUE ( 'Time Table'[Date] ) + timeSlicer
VAR prevDay = currentDay - 1
VAR result =
    CALCULATE (
        SUM ( 'Time Table'[Value] ),
        FILTER (
            ALL ( 'Time Table' ),
            'Time Table'[DateTime] < currentDay
                && 'Time Table'[DateTime] >= prevDay
        )
    )
RETURN
    result

 

To see the result - drag the new Date column and Total measure into a table

Result.png

 

Anonymous
Not applicable

Hey @Hennadii,

I tried your solution but it didn't work - It didn't show me any values.

I copied your steps and still it didn't work 😞

 

I really appreciate your help anyways!

 

Ariel

Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Try this measure 

Measure = 
VAR __end = TODAY() + TIME( 7, 0, 0 )
VAR __start = __end - 1
RETURN 
CALCULATE(
    SUM( 'Table'[Value] ),
    KEEPFILTERS( 
        'Table'[Datetime] >= __start &&
        'Table'[Datetime] < __end
    )
)

 

the result based on your sample will be.

image.png

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn


 

 

Anonymous
Not applicable

Hey @Mariusz ,

Your solution worked!

 

Thank you very much 🙂 

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.