Forum Discussion
How can I calculate absolute difference between two consecutive numbers in a column
Hi,
I want to calculate absolute difference of consecutive data points in a column for a filtered data. These set of values are based on 3 filters. Example, When I filter the data by Plant, Machine I get Flow rate by Batch Number. For these set of values I need to find absolute difference in consecutive points. Please see Moving Range column (required solution)
Please see the image below
8 Replies
- MattAllingtonCommunity Champion
Try this
current flowrate = max(table[flowrate])
Previous flow rate = calculate(max(table[flowrate]),filter(table,table[batch number] = max(table[batch number])-1))
MR =ABS([current flow rate] -[previous flow rate])
- niharika0913Frequent Visitor
Hi,
Thanks for your reply.
This doesn't work for me. That table is just for example, in my case, I have Date column which is unique per row and batch number is random because I filter my table to reach set of values for Flow rate.In Previous flow rate = calculate(max(table[flowrate]),filter(table,table[batch number] = max(table[batch number])-1)), if I use Date the result column is blank because date is unique but not continuous (max-1 fails here). I tried to create dynamic Row number using Dax measures but then filter() is not taking RowNum because it accepts table columns and not measure.
I created dynamic RowNum (suppose 10 rows after I filter data then it shows Row number 1-10 in table) because the batch Number from data is random and not sequential.
Is there any other way to calculate the Previous value??
- AnonymousNot applicable
Is there any reason to not base your calculation on previous date from the date column?