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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
feralvarez994
Helper II
Helper II

Calculate last amount per hour

Hi everyone! I need to get the last amount (MONTO column) of every BANK (BANCO/ENTIDAD column) by date and time (FECHA Y HORA Column).

I have a dax with CALCULATE with LASTDATE but it returns the first amount of the last day at the earlier hour, example if i have a value from today morning and another row with today afternoon, it only gets the first value(morning one) instead of the afternoon one

I need it to return the last value also having in consideration the hour

 

Can someone help me please? My dataset looks like this

feralvarez994_0-1653339124503.png

 

Thanks everyone

 

1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @feralvarez994,

 

You can use this code to get the result:

Measure =
VAR _S =
    SUMMARIZE (
        'Table',
        [BANCO/ENTIDAD],
        "LAST", CALCULATE ( SUM ( 'Table'[MONTO] ), TOPN ( 1, 'Table', [FECHAYHORA], DESC ) )
    )
RETURN
    SUMX ( _S, [LAST] )

vchenwuzmsft_0-1653558869471.png

 

Pbix file in the end you can refer.

 

Best Regards

Community Support Team _ chenwu zhu

 

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

View solution in original post

2 REPLIES 2
v-chenwuz-msft
Community Support
Community Support

Hi @feralvarez994,

 

You can use this code to get the result:

Measure =
VAR _S =
    SUMMARIZE (
        'Table',
        [BANCO/ENTIDAD],
        "LAST", CALCULATE ( SUM ( 'Table'[MONTO] ), TOPN ( 1, 'Table', [FECHAYHORA], DESC ) )
    )
RETURN
    SUMX ( _S, [LAST] )

vchenwuzmsft_0-1653558869471.png

 

Pbix file in the end you can refer.

 

Best Regards

Community Support Team _ chenwu zhu

 

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

amitchandak
Super User
Super User

@feralvarez994 , Create a new column

Date hour = datevalue([Date Time]) + time(hour([Date Time]),0,0)

 

 

a new measure =

calculate(lastnonblankvalue(Table([Date Time], sum(table[Value]), allexcept(Table, Table[Date hour] ) )

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.