I'm assuming you are referring to the tilemap object and tile ID.
Here is a quick hack -
I don't think there is any way to get the tilemap width and height from expressions, so you'll have to set the number X and Y to loop through manually.
Another way would be to have your tilemap mirror data in an array, and manipulate the array, as arrays seem to be much more flexible in terms of operations.