Select Page
You can filter data in a report to display information based on the distance between a location on the report, and the current location of an iPhone or iPad. For information on the requirements to support the Map widget on Android devices, refer to the MicroStrategy Readme. For example, in the image below, a report displays a list of stores.
Example of a list of store locations
When the report is viewed on a mobile device, the user can choose to display only stores within a ten mile radius.
List of store locations within a 5 mile radius
If the report is displayed as a Map widget, only map markers for stores within a ten mile radius are displayed.
Example of store locations in a 10 mile radius
To filter data based on the distance from a point of interest to a mobile device, you must first create a metric to calculate this distance. Steps are below to create this metric.
Once you have created the distance calculation metric, you can use it to filter data by creating a prompt or filter using the metric. For example, you can:
  • Create a prompt to allow users to display only data for locations within a specified radius of the mobile device
  • Create a filter to automatically display data only for locations greater than 10 miles away from the mobile device
  • In a Map widget, display map markers only for locations within a specified radius

Prerequisite

  • This procedure assumes that you have created an attribute with attribute forms containing the latitude and longitude of each location to use for the distance calculation. For example, the Store attribute in the example above has two attribute forms, Latitude and Longitude, which contain the latitude and longitude information for each store.

To create a metric to calculate the distance between locations and a mobile device

  1. From any folder page, click the Create Prompt Create Prompt icon icon. The Create Prompt page is displayed.
  2. Click Value Prompt. A list of options for creating a value prompt is displayed.
  3. On the Definition tab, select the Numeric prompt option.
  4. On the General tab, specify a title for the prompt in the Title field. The title is displayed along with the prompt when the prompt is run.
  5. On the Style tab, from the Display style drop-down list, select Geo Location.
  6. To specify whether the mobile device will automatically provide its latitude or longitude to answer the prompt, select the Latitude option under Location Coordinate. You will create a total of two Value prompts, one to specify latitude and one to specify longitude.
  7. To save the prompt, select Save As. The Save As dialog box opens. Specify a name, description, and the location in which to save the prompt, then click OK. The prompt is saved.
  8. Repeat the steps above, selecting the Longitude option under Location Coordinate to create a second Value prompt for the longitude. You must create a total of two prompts, one for the mobile device’s longitude and one for the latitude.
  9. To create the distance calculation metric, you must perform the following steps in MicroStrategy Desktop for several metrics, as listed in the table below. The table lists each metric to create, and the formula to use to create the metric, in the order in which you must create them. The final metric, Point_Distance, is the distance calculation metric.
  10. In Desktop, from the File menu, point to New, and then Metric. The New Metric dialog box opens.
  11. Click OK to create a new metric. The Metric Editor opens.
  12. In the Definition pane, type the formula of the metric you want to create. Use the syntax in the table below for the metric’s definition.
  13. Click Save and Close. The Save As dialog box opens.
  14. In the Object name field, type the name of the new metric. Use the name provided in the table below.
  15. Navigate to the location in which you want to save the new metric, then click Save. The new metric is created.
  16. Repeat the appropriate steps above to create each of the metrics required to calculate the distance to each store.
  17. Once you have created the distance calculation metric, Point_Distance, you can create a prompt or filter that will use the metric. You can:
    • Create a Metric Qualification prompt and add the prompt to a report, to let users specify a distance radius for which to display data. When the report is displayed on a mobile device, the user is presented with a prompt.
    • Create a Metric Set Qualification filter. You can add the filter to a report or to a dataset report in a document, to automatically filter the data using the current location of the mobile device.
    • Create a prompt or filter that will use the metric, then add it to a report displayed as a Map widget, or to the dataset report of a Map widget in a document. When the Map widget is displayed on a mobile device, only the map markers for locations within the specified distance from the mobile device are displayed. For general information and steps to define a Map widget, see Creating a Map widget for mobile devices.
The table below lists the metrics to create for the distance calculation metric, in the order they must be created.
Metric Name
Metric Definition
Location_Lat
Max(AttributeName@LatitudeFormName)
Replace AttributeName with the name of the location attribute, and replace LatitudeFormName with the attribute form that contains the latitude information for each location. For example, for an attribute named Store with the attribute forms Latitude and Longitude, create a metric with the name Location_Lat, with the definition Max(Store@Latitude).
Location_Long
Max(AttributeName@LongitudeFormName)
Replace AttributeName with the name of the location attribute, and replace LongitudeFormName with the attribute form that contains the longitude information for each location. For example, for an attribute named Store with the attribute forms Latitude and Longitude, create a metric with the name Location_Long, with the definition Max(Store@Longitude).
DeltaLat/2
(Radians(([Location_Lat] – ?LatitudePromptName)) / 2)
Replace LatitudePromptName with the name of the Value prompt for latitude. For example, if the Value prompt is named Latitude, the definition is (Radians(([Location_Lat] – ?Latitude)) / 2).
DeltaLong/2
(Radians (([Location_Long] – ?LongitudePromptName))/2)
Replace LongitudePromptName with the name of the Value prompt for longitude. For example, if the Value prompt is named Longitude, the definition is (Radians(([Location_Long] – ?Longitude)) / 2).
A
((Sin([DeltaLat/2]) * Sin([DeltaLat/2])) + (((Cos(Radians(?Latitude)) * Cos(Radians([Location_Lat]))) * Sin([DeltaLong/2])) * Sin([DeltaLong/2])))
C
(2 * [Atan2](Sqrt((1-A)), Sqrt(A)))
Point_Distance
(3959 * C)
Note: This value is based on the radius of the Earth, 3,959 miles or 6,371 km. To calculate the distance between the stores and the mobile device using a different unit of distance, replace 3959 with the radius of the Earth in the units you want to use to measure distance. For example, to calculate distance in kilometers, the metric definition is (6371 * C).
Secured By miniOrange