Filter relative comparison

Hello all,

I use filter to comparison but I want relative comparison ± 0.05. Thank all
Amount column: 10602.38
Tong Tien column: 10602.39

@anh.nguyen

"[Amount] >= " + (10602.38 - 0.05).ToString + " And [Amount] <= " + (10602.39 + 0.05).ToString

Hope this works

1 Like

Hi,

Unfortunately, FilterDataTable activity doesn’t support such calculation.
Can you try as the following?

arrDr = dt.AsEnumerable.Where(Function(r) Math.Abs(CDbl(r("Amount"))-CDbl(r("Tong Tien")))<=0.05).ToArray()

Note: arrDr is DataRow array type.

Regards,

1 Like

Hi @Yoichi

Because i need to compare 2sheet. How can I use your code ?
Assign: Column ‘Tổng Tiền’ does not belong to table DataTable.

“Tổng Tiền” column in dt2
“AMOUNT” column in DTfilter

Hi,

Do you want to compare same row index data in both datatable?

If so,can you try the following expression. it’s unnecesary to use ForEachRow activity.

dtFilter = dt.AsEnumerable.Where(Function(r,i) Math.Abs(CDbl(r("Amount"))-CDbl(dt2.Rows(i)("Tong Tien")))<=0.05).ToArray()

Regards,

hi, when I assign have some issues, and the condition for true? Thank you

Hi,

Sorry, It’s my mistake. Can you try to use arrDR (DataRow array type) as the following? (Because if there is no row in filtered datatable, it will throws error)

Regards,