Forum Discussion
get value from previous row
- 3 years ago
Hi , Anonymous
According to your description, you want to "get value from previous row".
First , you need to sort the [DateTime] in Power Query and you need to check the [DateTime] is single value in each row. IF not , you need to add an index column in Power Query Editor as a row number to judge .
Here, i use your [DateTime] as a row number to check which row is calculating.
Then we can click "New Column" to add a calculated column by this dax code:
Column = var _cur_row = [DateTime] var _t =ADDCOLUMNS( FILTER('Table' , 'Table'[DateTime]<= _cur_row) , "cal" , [IN] - [OUT]) return SUMX(_t ,[cal])Then we can meet your need:
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- 3 years ago
hi Anonymous
you may also add a calculated column like:
INSIDE2 = SUMX( FILTER( TableName, TableName[DateTime]<=EARLIER(TableName[DateTime]) ), TableName[IN] - TableName[OUT] )it worked like:
hi Anonymous
you may also add a calculated column like:
INSIDE2 =
SUMX(
FILTER(
TableName,
TableName[DateTime]<=EARLIER(TableName[DateTime])
),
TableName[IN] - TableName[OUT]
)
it worked like: