Generating constants with SELECT statements

During the development of a BI project, sometimes we need to use values which do not necessarily come from tables; these can be constants such as Data refreshed at or Today. The logical tables come in very handy for this purpose.

Getting ready

You can find the SELECT statement for this recipe in the companion code file.

How to do it...

To create a logical table that returns the current date as a constant, do the following:

  1. Go to the Schema Objects | Tables folder and right-click on an empty space in the right pane. From the context menu, choose New | Logical Table.
  2. In the SQL statement text area, paste this sentence:
    select DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0) DateValue
    
  3. Add one Column Object and name ...

Get Business Intelligence with MicroStrategy Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.