The Virtual Data Port retrieves data in realtime from the underlying source and displays the result as it is in the source. Hence, if the data returned from the source is not ordered, I would use Order by clause to get the data in an orderly manner.
In order to achieve “cast(a11.opr_id as varchar(10)) in (@id) or ‘ALL’ in (@idx)” in Virtual DataPort, I would use CASE statement as below,
`CASE WHEN <condition> THEN id ELSE idx END`
To know more about the order by clause and CASE statement, refer to [ORDER BY Clause](https://community.denodo.com/docs/html/browse/latest/en/vdp/vql/queries_select_statement/order_by_clause/order_by_clause#order-by-clause) and [CASE Clause](https://community.denodo.com/docs/html/browse/latest/en/vdp/vql/queries_select_statement/case_clause/case_clause#case-clause) sections of Virtual DataPort VQL Guide respectively.
Hope this helps!