Forum Discussion
Identify canceled items
- 5 years ago
Hi, mb0307
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may create an index column in Power Query and then create a calculated column as below.
Result = var tab = CALCULATETABLE( 'Table', FILTER( 'Table', [Canceled Order] = 2&& [Order]=EARLIER('Table'[Order])&& [Date]=EARLIER('Table'[Date])&& [Item]=EARLIER('Table'[Item])&& [Quantity]=EARLIER('Table'[Quantity])&& [Batch]=EARLIER('Table'[Batch]) ) ) var minindex = CALCULATE( MIN('Table'[Index]), FILTER( 'Table', [Order]=EARLIER('Table'[Order])&& [Date]=EARLIER('Table'[Date])&& [Item]=EARLIER('Table'[Item])&& [Quantity]=EARLIER('Table'[Quantity])&& [Batch]=EARLIER('Table'[Batch])&& [Canceled Order]=EARLIER('Table'[Canceled Order]) ) ) return IF( COUNTROWS(tab)>0&&[Index]=minindex, "REMOVE","KEEP" )Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, mb0307
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may create an index column in Power Query and then create a calculated column as below.
Result =
var tab =
CALCULATETABLE(
'Table',
FILTER(
'Table',
[Canceled Order] = 2&&
[Order]=EARLIER('Table'[Order])&&
[Date]=EARLIER('Table'[Date])&&
[Item]=EARLIER('Table'[Item])&&
[Quantity]=EARLIER('Table'[Quantity])&&
[Batch]=EARLIER('Table'[Batch])
)
)
var minindex =
CALCULATE(
MIN('Table'[Index]),
FILTER(
'Table',
[Order]=EARLIER('Table'[Order])&&
[Date]=EARLIER('Table'[Date])&&
[Item]=EARLIER('Table'[Item])&&
[Quantity]=EARLIER('Table'[Quantity])&&
[Batch]=EARLIER('Table'[Batch])&&
[Canceled Order]=EARLIER('Table'[Canceled Order])
)
)
return
IF(
COUNTROWS(tab)>0&&[Index]=minindex,
"REMOVE","KEEP"
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-alq-msft exactly what i wanted. Thanks a lot for your help.