Hi Sarthak Patel,
You can update your code as below,
This should work, Thanks!
Indeed use the power of the page structure.
Though I want to add a bit more:
This XPath [contains(OfficeID, $Location/LocationID)] gives me the impression you don't use associations properly.
My gestimation is that one Location can contain multiple offices and one office is located on one location?
Then instead of adding ID attributes use associations. Which will allow you to show a dataview wit a single Location and a nested Listview over association showing the referenced offices.
Take a look at this lecture https://gettingstarted.mendixcloud.com/link/module/82/lecture/635/4.8-Associations-in-the-Domain-Model