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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

DAX: Group results from Measure by Day and Hour

The following formula shows the difference between 1 row and the last. I spent a long time working on this and needed the help of someone here to get it to this point. But the result is showing the difference PER ENTRY, while I am looking for PER DAY and PER HOUR. 

 

BPS = 
VAR _currentlastvalue =
    CALCULATE ( SUM ( 'Table'[Value]), 'Table'[Date] = MAX ( 'Table'[Date] ) )
VAR _prevlasttime =
    MAXX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Item] = MAX ( 'Table'[Item])
                && 'Table'[Date] < MAX ( 'Table'[Date] )
        ),
        'Table'[Date]
    )
VAR _prevlastvalue =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table'),
            'Table'[Item] = MAX ( 'Table'[Item] )
                && 'Table'[Date] < MAX ( 'Table'[Date] )
                && 'Table'[Date] = _prevlasttime
        )
    )
RETURN
        IF (
        ISINSCOPE ( 'Table'[Date] ) && ISINSCOPE ( 'Table'[Item] ),
        SWITCH (
            TRUE (),
            _prevlastvalue <> BLANK (), _currentlastvalue - _prevlastvalue,
            _prevlastvalue = BLANK (), 0
        )
    )

 

 

So I believe a Summarize function is needed to group this measure into days and hours. Perhaps I'll need 2 separate measures, which is fine.

 

Thank you!

1 REPLY 1
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

What does your raw data look like?

Sorry for that the information you have provided is not making the problem clear to me. Can you please share more details to help us clarify your scenario?

Please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

 

Refer to:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

 

Best Regards,

Jianbo Li

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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.