MicroStrategy ONE

Using prompts for arguments

Prompts can be used to provide the value for an argument in a function, which allows a user to determine part of the function definition when a report is executed. The most common arguments to use prompts for are arguments that expect a single value. For example, the function NTileSize has the following syntax:

NTileSize <Ascending, BreakBy> (Argument,Size)

The two arguments for this syntax are:

  • Argument is a metric representing a list of values to be distributed in buckets.

  • Size is a positive integer that designates the number of elements per bucket.

The argument Size is a good candidate to use a prompt for, since it expects a single value. Using a prompt to provide the value for Size allows a user to determine how many elements should be included in each NTile bucket. This is a more flexible reporting solution than defining a static value for the argument that is always used for the calculation.

To include a prompt in a function expression, you can use the following syntax:

?[Prompt Name]

The Prompt Name is the name of the prompt object. For example, you can have the following definition:

NTileSize([Total Revenue], ?[NTileValue Prompt])

In the syntax shown above, NTileValue Prompt is the name of a value prompt that supplies the size for the NTileSize function.

When prompts are created, you can choose whether answering the prompt is optional or required. Since arguments are required for a function to work properly, it is a good practice to define prompt answers as required if the prompt is going to be used in a function expression.

Many of the financial functions use arguments that expect a single value, and thus are good candidates for using functions to provide their values. For example, the function Coupdays includes a Frequency argument which can accept the value of 1, 2, or 4 to determine the number of coupon payments per year. You could use a value prompt for the Frequency argument to prompt the user to enter the frequency of the coupon payments.