EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

KB6178: How to use the pass-through expression ApplyComparison in MicroStrategy SQL Generation Engine


Community Admin

• Strategy


This article explains how to use the applycomparison function in MicroStrategy

INTRODUCTION
 
Pass-through expressions, also called Apply functions, provide access to special functions or syntactic constructs that are not standard in Strategy, but can be obtained through the relational database. They act as containers for non-standard SQL expressions that Strategy does not support.
The Apply functions are not meant to take the place of the standard Strategy functions. Instead, they are intended to enhance the Strategy product by taking advantage of what the RDBMS platforms can offer. There are five predefined Apply functions, each belonging to a different function type - ApplySimple, ApplyAgg, ApplyOLAP, ApplyComparison, ApplyLogical. In this article we will discuss the ApplySimple function.
 
ApplyComparison
The ApplyComparison function is similar to the ApplySimple function KB3905: How to use pass-through expression- ApplySimple in MicroStrategy SQL Generation Engine  which allows users to send direct input to the warehouse in filtering expressions. This function can only be used in the filter editor.
SYNTAX:
ApplyComparison ("expression_with_placeholders", parameter_1, …, parameter_n)
 
Where: 'expression_with_placeholders' is a valid SQL expression for the DBMS using placeholders with the format '#n'. '#' is a reserved character for Strategy and 'n' is the number of the parameters (arguments) outside the quotes, starting with '0' and increasing in steps of '1'.
'parameter_1, …, parameter_n' is the list of parameters that will replace the placeholders inside the quotes. The parameters can be attribute forms, value prompts or constants. An attribute form parameter must follow the following syntax:
attribute_name@form_name
 
Example:
This example shows how a dynamic date filter with a prompt can be created against a SQL Server database, the objects needed are:
Metric:
[M1]: Sum([Dollar Sales]) {~+}
Value prompt:
[P1]: Numeric value prompt.
Custom expression filter with apply comparison expression:

ka04W00000148kUQAQ_0EM440000002GCL.gif

Filter:
[Last 7 Days]:
  [Custom expression]:
ApplyComparison ("#0 BETWEEN DateAdd(Day, -#1, Getdate()) AND Getdate()", Date@ID, ?[P1])
In SQL Server:

  1. The DateAdd() function adds the specified number of units to a date. A unit is a time unit (i.e., day, month, year, minute, etc.)
  2. The Getdate() function returns the SQL Server's system date

This filter will prompt on a value, and generate a WHERE clause that returns a range of days between the database server's date and the same date minus the number of days entered at run time in the prompt.
A report with [Date], [M1] and [Last 7 Days] returns:
 

Setting
LocationDescriptionRequest timeout40sWeb admin page > DefaultHow long Web waits for a response for XML commands sent to the Intelligence server.Server busy timeout10sWeb admin page > DefaultHow long Web waits for a free TCP connectio to Intelligence server, if the maximum connection pool is reached.Request timeout to check if the Intelligence Server is alive3ssys-defaults.xml > isAliveRequestTimeoutMillisStrategy Web submits a get folder ID command to Intelligence Server to verify if Intelligence Server is still alive.Element search request timeout50sFrameProcessor.xml > <propertyname="timeout">The timeout that occurs when performing a search in an element prompt. See KB46608 for more information.Data import query builder request timeout600s (10m)sys_defaults.xml > DIAlternativeSessionRequestTimeoutData import query builder request timeout. See KB273065 for more information.IIS session timeoutsvariesIIS ManagerSee KB41860 for more information.Tomcat JSP session timeout30m\WEB-INF\web.xml: <session-timeout>30</session-timeout>Timeout for inactive JSP sessions. See KB12966 for more information.IIS request timeout110sIIS Manager > system.web > httpRuntimeSee KB35666 for more information.HTTP server/proxy/firewall request timeoutvariesSee your third-party software documetnation.When there is a long running HTTP request, this setting determines how long until the HTTP server, proxy, or firewall cancels the HTTP request and returns an error status code.GRIDSQL

Setting
LocationDescriptionRequest timeout40sWeb admin page > DefaultHow long Web waits for a response for XML commands sent to the Intelligence server.Server busy timeout10sWeb admin page > DefaultHow long Web waits for a free TCP connectio to Intelligence server, if the maximum connection pool is reached.Request timeout to check if the Intelligence Server is alive3ssys-defaults.xml > isAliveRequestTimeoutMillisStrategy Web submits a get folder ID command to Intelligence Server to verify if Intelligence Server is still alive.Element search request timeout50sFrameProcessor.xml > <propertyname="timeout">The timeout that occurs when performing a search in an element prompt. See KB46608 for more information.Data import query builder request timeout600s (10m)sys_defaults.xml > DIAlternativeSessionRequestTimeoutData import query builder request timeout. See KB273065 for more information.IIS session timeoutsvariesIIS ManagerSee KB41860 for more information.Tomcat JSP session timeout30m\WEB-INF\web.xml: <session-timeout>30</session-timeout>Timeout for inactive JSP sessions. See KB12966 for more information.IIS request timeout110sIIS Manager > system.web > httpRuntimeSee KB35666 for more information.HTTP server/proxy/firewall request timeoutvariesSee your third-party software documetnation.When there is a long running HTTP request, this setting determines how long until the HTTP server, proxy, or firewall cancels the HTTP request and returns an error status code.GRIDSQL



Data Rows: 6
Data Columns: 1

select a11.Order_Date DATE_ID,
  sum(a11.ORDER_AMT) M1
from   ORDER_FACT a11
where   a11.Order_Date BETWEEN DateAdd(Day, -7, Getdate()) AND Getdate()
group by   a11.Order_Date

Notice how '#0' is replaced with the first parameter outside the quotes ( form for the [Date] attribute), the second parameter ('#1') is replaced by the answer to the value prompt (7) and the SQL is placed after the WHERE clause.



Data Rows: 6
Data Columns: 1

select a11.Order_Date DATE_ID,
  sum(a11.ORDER_AMT) M1
from   ORDER_FACT a11
where   a11.Order_Date BETWEEN DateAdd(Day, -7, Getdate()) AND Getdate()
group by   a11.Order_Date

Notice how '#0' is replaced with the first parameter outside the quotes ( form for the [Date] attribute), the second parameter ('#1') is replaced by the answer to the value prompt (7) and the SQL is placed after the WHERE clause.

 


Comment

0 comments

Details

Knowledge Article

Published:

April 5, 2017

Last Updated:

September 15, 2017