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

Calculate multiple increments on cumulative value for non-regular timestamps

Hello,

 

I've been struggling with this one for a while.

I have a table of 3 columns.

  1. A list of asset names
  2. A timestamp when a specific value was recorded
  3. The recorded value

My table shows the recorded value at a specific time for that asset.

 

I have the same name multiple time as I have many records for that asset.

The timestamp are not regular. it could be multiple time per day, or none in a week. 

The values are cumulative per asset. I can have the same value for the same asset multiple time if I get a new recorded time with the same value.

 

I am looking to do a measure that calculates for each asset, and per day, the increment compared to the last recorded value.

For one asset:

  • if I have 1 value for a day, I want that value minus the previous recorded value
  • if multiple values on the same day, I want the max on that day, minus the previous recorded value.
  • if no value on the day, I want the previous recorded value.

I tried to create a new column, but my list is so big powerbi crashes before finishing the calculation (even increasing the allocated memory). I think that the measure is the only option.

 

If anyone could help, that would be amazing !

 

Thank you beforehand

 

Here's a portion of my table:

 

NameTimestampValue
AN112/28/2022 10:22:07 PM284.1
AN133/1/2022 4:09:01 AM417.7
AN123/8/2022 3:33:05 AM809.8
AN123/8/2022 10:54:23 PM810
AN13/9/2022 7:12:04 AM852.1
AN123/9/2022 3:14:38 PM810.3
AN13/10/2022 4:49:01 AM852.3
AN123/10/2022 10:50:59 AM810.4
AN13/10/2022 10:39:49 PM852.6
AN13/12/2022 6:20:03 AM852.8
AN13/13/2022 5:27:13 AM853.1
AN13/14/2022 3:49:27 AM853.3
AN13/15/2022 12:56:18 AM853.4
AN133/16/2022 10:56:13 PM417.9
AN103/17/2022 4:12:58 AM780.5
AN123/17/2022 12:45:44 PM810.6
AN133/17/2022 10:04:04 PM418.2
AN123/18/2022 6:36:51 AM810.9
AN133/18/2022 9:56:49 PM418.4
AN13/18/2022 10:11:53 PM853.5
AN153/19/2022 6:59:45 AM1578.2
AN123/19/2022 2:32:09 PM811.1
AN133/20/2022 6:37:21 AM418.7
AN123/20/2022 8:41:55 PM811.4
AN133/21/2022 12:28:07 AM418.9
AN123/21/2022 11:46:45 AM811.6
AN133/21/2022 10:20:07 PM419.2

 

3 REPLIES 3
v-stephen-msft
Community Support
Community Support

Hi @Tcorentin ,

 

Here's my solution.

1.Create a date column and a rank column by calcualted columns.

Date = [Timestamp].[Date]
rank = RANKX(FILTER('Table',[Name]=EARLIER('Table'[Name])),[Timestamp],,ASC,Dense)

vstephenmsft_0-1680681144233.png

2.Create three measures.

CurrentMax = CALCULATE(MAX('Table'[Value]),FILTER(ALLSELECTED('Table'),[Name]=MAX('Table'[Name])&&[Date]=MAX('Table'[Date])))
PreviousValue = CALCULATE(MAX('Table'[Value]),FILTER(ALLSELECTED('Table'),[rank]=MAX('Table'[rank])-1&&[Name]=MAX('Table'[Name])))
Increment = [CurrentMax]-[PreviousValue]

vstephenmsft_1-1680681185661.png

 

                                                                                                                                                         

Best Regards,

Stephen Tao

 

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

Thank you very much for your help.

I just have three points:

  • I would like to see the values for everyday. If there are no recorded value, then I want my increment to be of 0. Currently, for days with no values, the date doesn't even show up.
    Tcorentin_1-1680699560291.png

     

  • The first value for every asset is a full value (as it doesn't have a previous value). Because some asset have their first recorded value at very different time, that upsets my overall analysis as I get high values for one day when I want to calculate average and max per day. How could we make the first value per asset 0 ? 

Tcorentin_2-1680699602370.png

 

  • When I try to graph for all names, I have negatives increments (see visual), how can we explain that as the individual increments are all positive ?

Tcorentin_0-1680699412255.png

 

thank you again ! 

Regarding negative increments. I did some troubleshooting and realized that my dataset have some 0 values in the middle.

Tcorentin_0-1680701753399.png

 

that means that my increments goes down and back up:

Tcorentin_1-1680701798872.png

it happens quite a lot. I updated the Increment measure:

Increment = IF(OR([CurrentMax]=0,[PreviousValue]=0),0,[CurrentMax]-[PreviousValue])
my new total increment per day is now all negative 😞 how can I explain that ?
Tcorentin_0-1680704705095.png

 

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.