Forum Discussion

Dunner2020's avatar
Dunner2020
Post Prodigy
6 years ago

Creating new column values based on previous rows value

Hi there,

 

I have a table that contains 3 columns (index, Waste Value, Running total of waste value). I want to create or populate new column/measure  (let say called Replaced Value) in such a way that if Running Total value (which is cumulative sum of 48 values of column named waste value) exceeds a certain threshold (let say 150), then it checks 48 past values of the column  'waste value'  and sees if the waste column value is greater than 10 then put 10 in Replaced value column otherwise copy the same value of 'waste value' column into Replaced Value column. Here is how the structure of the table looks like:

 

Date TimeWaste ValueRunning TotalReplaced Value
1/01/2000 0:002 2
1/01/2000 0:303 3
1/01/2000 1:004 4
1/01/2000 1:305 5
1/01/2000 2:006 6
1/01/2000 2:307 7
1/01/2000 3:008 8
1/01/2000 3:309 9
1/01/2000 4:000 0
1/01/2000 4:301 1
1/01/2000 5:002 2
1/01/2000 5:3013 10
1/01/2000 6:0014 10
1/01/2000 6:3016 10
1/01/2000 7:0011 10
1/01/2000 7:302 2
1/01/2000 8:002 2
1/01/2000 8:308 8
1/01/2000 9:009 9
1/01/2000 10:000 0
1/01/2000 10:304 4
1/01/2000 11:008 8
1/01/2000 11:309 9
1/01/2000 12:000 0
1/01/2000 12:3011 10
1/01/2000 13:002 2
1/01/2000 13:303 3
1/01/2000 14:004 4
1/01/2000 14:305 5
1/01/2000 15:006 6
1/01/2000 15:307 7
1/01/2000 16:008 8
1/01/2000 16:309 9
1/01/2000 17:0022 10
1/01/2000 17:303 3
1/01/2000 18:0021 10
1/01/2000 18:301 1
1/01/2000 19:002 2
1/01/2000 19:308 8
1/01/2000 20:007 7
1/01/2000 20:306 6
1/01/2000 21:005 5
1/01/2000 21:304 4
1/01/2000 22:003 3
1/01/2000 22:302 2
1/01/2000 23:009 9
1/01/2000 23:3062976
1/02/2000 0:0053005
1/02/2000 0:3043014
1/02/2000 1:0033003
1/02/2000 1:3063016
1/02/2000 2:0083038
1/02/2000 2:301130710
1/02/2000 3:001231110

 

For example, Running total value exceeds 150 when Date Time value is '1/01/2000 23:30'. To generate 'Replaced Value' column, it starts looking back 48 values of waste value column, if the value of the waste column is more than 10, then the value of Replaced Value column would be 10 (as shown in blue color) otherwise it would be same as the waste column is. I hope that clarifies the confusion. 

 

 
 

Could anyone guide me how can we do in power BI?

 

 

6 Replies