The macro needs to go into the where condition of the data source or repeater that you are using to access that data.
Make sure your query looks something like:
SELECT ##TOPN## ##COLUMNS## FROM customtable_test WHERE (##WHERE##) ORDER BY ##ORDERBY##
Navigate to the page you want to show the data on and use a Query data source to get the data:
Query Name: select your query
Where condition: active='yes' AND ItemID={%ItemID%}
if the itemid is passed in as a url parameter you can do {%QueryString.ItemID|(identity)GlobalAdministrator%} or {% itemID %}
Selected columns: Dates
Make sure you enter the where condition into the Edit Value dialog. You can access it by clicking the black triangle next to the Where text box
Then use a basic repeater to display the data
Data source name: QueryDataSource (or whatever name you gave your data source web part)
Make sure you have also created a transformation to display that data
If there is an error or the data isnt showing check the Event Log
If you want to see the SQL query generated, check out the Debug. Go into Settings > System > Debug to enable debugging
Some helpful pages:
Loading data using custom queries
Entering macro expressions
Displaying data from custom tables
Writing transformations
Check Event log
Debugging SQL queries