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
Nico_Beckers
Frequent Visitor

Difference between current and previous cell, reset every new day

Hello, 

 

I have this kind of data set:

DateTimeAccumulative countAmount per hour
01/05/202201:0011
01/05/202202:0021
01/05/202203:0075
01/05/202204:0092
01/05/202205:00156
02/05/202201:0033
02/05/202202:0096
02/05/202203:00123
02/05/202204:002513
02/05/202205:00283
03/05/202201:0000
03/05/202202:001515
03/05/202203:00183
03/05/202204:00191
03/05/202205:00234

 

So basicly I have an accumulative count, that gets reset every day at a certain time. What I want to know is the amount per hour, but reset every day. I tried with a merged double index, one starting at 0, the other at 1, but then I dont take the dates into account.

 

Anyone has an idea how to fix this in power query?

 

Many thanks!

Nico

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Nico_Beckers , Try a new column like

 

New column =
var _date = datevalue([Date Time])
var _max = maxx(filter(Table, [Date Time] < earlier([Date Time]) && datevalue([Date Time]) = _date), [Date Time] )
return
[Accumulative] - maxx(filter(Table, [Date Time] =_max && datevalue([Date Time]) = _date), [Accumulative] )

View solution in original post

4 REPLIES 4
Nathaniel_C
Super User
Super User

Hi @Nico_Beckers ,
Please try this:

Dax Accumulative Count =
VAR _date =
    MAX ( dif[Date] )
VAR _Time =
    MAX ( dif[Time] )
VAR _amountPerHour =
    MAX ( dif[Amount per hour] )
VAR _calc =
    CALCULATE (
        SUM ( dif[Amount per hour] ),
        FILTER ( ALL ( dif ), dif[Date] = _date && dif[Time] <= _Time )
    )
RETURN
    _calc


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

Nathaniel_C_0-1654048645765.png

 





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

Proud to be a Super User!




Hi Nathaniel, 

 

This gives me the accumulative count no? I want to calculate the amount per hour starting from the accumulative count. Or did I miss something?

Hi @Nico_Beckers ,
Sorry for misunderstanding. Still not sure what you want. Perhaps you could provide a picture of your expected outcome. 

Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





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

Proud to be a Super User!




amitchandak
Super User
Super User

@Nico_Beckers , Try a new column like

 

New column =
var _date = datevalue([Date Time])
var _max = maxx(filter(Table, [Date Time] < earlier([Date Time]) && datevalue([Date Time]) = _date), [Date Time] )
return
[Accumulative] - maxx(filter(Table, [Date Time] =_max && datevalue([Date Time]) = _date), [Accumulative] )

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.