Passing Element Prompt Answers to Database Passthrough Functions
A common request is for the ability to use an element prompt to choose a month or day, and then based on that selection, choose a range such as a rolling months or rolling days. The problem is that if you build out this prompt, ApplyComparison(“#0 in (select month from tblmonth where month >= #1”, Month@ID, ?Month), this would result in the SQL: “a11.Month in (select month from tblmonth where month >= a11.Month in(6)” which is not valid SQL. Since an element prompt generally appears in the Where clause, the engine resolves them all using an in operator instead of =. Fortunately, MicroStrategy 9.0 introduced a new feature to support this type of scenario
The trick is that instead of using the macro #1, which traditionally will pass the field at the end of the function, we use the new macro #E1 to tell MicroStrategy that we’re passing an element prompt answer. The engine will now adjust the query so that instead of generating a11.Month in(6), it will simply pass 6.
For more information, you can check out this Tech Note on the Knowledge Base.