Forum Discussion
nates05
6 years agoFrequent Visitor
Running Total Difference between each Time Period
Hi, my data is below. I generate data that is a running total of items sold ("Total Sold") per item and wanted to generate values that measures the difference between periods ("Sold per period")....
- 6 years ago
Hi nates05 ,
You can try my method:
At first, create a new column "rank".rank = RANKX ( 'Table', 'Table'[Period],, ASC, DENSE )
Then create your goal column.
Sold per period = VAR a = CALCULATE ( FIRSTNONBLANK ( 'Table'[Total Sold], 1 ), FILTER ( 'Table', 'Table'[Serial Codes] = EARLIER ( 'Table'[Serial Codes] ) && 'Table'[rank] = EARLIER ( 'Table'[rank] ) - 1 ) ) RETURN 'Table'[Total Sold] - aHere is the result.
Best Regards,
Eads
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-eachen-msft
6 years agoCommunity Support
Hi nates05 ,
You can try my method:
At first, create a new column "rank".
rank = RANKX ( 'Table', 'Table'[Period],, ASC, DENSE )
Then create your goal column.
Sold per period =
VAR a =
CALCULATE (
FIRSTNONBLANK ( 'Table'[Total Sold], 1 ),
FILTER (
'Table',
'Table'[Serial Codes] = EARLIER ( 'Table'[Serial Codes] )
&& 'Table'[rank]
= EARLIER ( 'Table'[rank] ) - 1
)
)
RETURN
'Table'[Total Sold] - a
Here is the result.
Best Regards,
Eads
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- nates056 years agoFrequent Visitor
v-eachen-msft that worked! thank you!
- nates056 years agoFrequent Visitor
Hi, would this have an M code equivalent?
I realized I need to insert these columns in power query itself.
Thanks!