Forum Discussion
Formula Help
Hi Anonymous ,
We can use the following steps to meet your requirement.
1. Create an index column in Power Query Editor.
2. Then we can create two calculated column.
Column =
VAR x =
CALCULATE (
SUM ( 'Table'[Compl OP Qty] ),
FILTER (
'Table',
'Table'[Index]
= EARLIER ( 'Table'[Index] ) - 1
&& 'Table'[OrderID] = EARLIER ( 'Table'[OrderID] )
)
)
VAR y =
IF ( ISBLANK ( x ), 0, x )
RETURN
IF (
'Table'[Compl OP Qty] = y,
'Table'[Compl OP Qty],
IF (
'Table'[Compl OP Qty] < y,
'Table'[Compl OP Qty],
IF ( y = 0, 'Table'[Compl OP Qty], y )
)
)
Column 2 =
VAR x =
CALCULATE (
SUM ( 'Table'[Column] ),
FILTER (
'Table',
'Table'[Index]
= EARLIER ( 'Table'[Index] ) - 1
&& 'Table'[OrderID] = EARLIER ( 'Table'[OrderID] )
)
)
var y = IF(ISBLANK(x),'Table'[Column],x)
return
ABS('Table'[Column]-y)
The result like this,
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello,
This looks perfect. Thank you for the assistance. I am still receiving issues. When attempting to add custom column, I receive an error after copying and pasting the provided formula. The error reads "Token Eof expected" .
- v-zhenbw-msft6 years agoCommunity Support
Hi Anonymous ,
Please create two calculate columns in Power BI Desktop not custom column in Power Query Editor. Please refer to following screenshot.
If you have any questions, please kindly ask here and we will try to resolve it.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous6 years agoNot applicable
Hello,
I was able to input them into a calcualted column, but I am still seeing errors. In workflow. Is there a way to attach an excel spreadsheet to this forum?
- v-zhenbw-msft6 years agoCommunity Support
Hi Anonymous ,
Please upload your files to OneDrive For Business and share the link here.
Please don't contain any Confidential Information or Real data in your reply.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.