A program snippet, such as the one below, would work for this purpose. The Boolean variable can be toggled from the Ports & Flags screen in LoggerNet (accessed via the Connect screen), through the Numeric Display (also accessed via the Connect screen), or under program control.
public StoreDataFlag as boolean
DataTable (ConditionalTable,StoreDataFlag,100)
Sample (1,counter,Long)
EndTable
When storing data conditionally, be sure to allocate a specific number of records in the size parameter of the DataTable() instruction. For more information, see the Data Table Memory Allocation Tutorial.