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

KB4180: How to implement attribute-to-attribute comparisons


Community Admin

• Strategy


The Strategy Product Suite allows comparisons between attributes. This document provides the steps to implement attribute to attribute comparison and provides information regarding how a join is made between tables to perform this comparison.
 
The steps below have been provided based on the Strategy Tutorial Project. To illustrate the example discussed below, the warehouse data has been modified.
 
The 'Order Date' attribute from the Strategy Tutorial project records the date an order is placed. Another attribute, 'Ship Date', records the date the order is shipped. If a report is required to show orders that are shipped on the same date, a filter that can perform a comparison between these two attributes is necessary.
 
The following report displays all customers, their orders, order and shipping dates and each order's sales figures.
 

ka04W000000OcUIQA0_0EM440000002GKa.gif

 
Notice that the highlighted row is the only row in which an order has the same order and shipping date.
 
The desired report should appear as follows:
 

ka04W000000OcUIQA0_0EM440000002GKT.gif

 
This report displays the customer, order, date and sales for all orders shipped the same day they were placed. The Filter Details pane displays the attribute-to-attribute comparison information.
 
STEPS TO CREATE FILTER:
 
To create this filter, an attribute qualification has to be added to the report, as illustrated below:
 

ka04W000000OcUIQA0_0EM440000002GKR.gif

 
The definition of the filter is as follows:
 

ka04W000000OcUIQA0_0EM440000002GKP.gif

 

  1. Select the Ship Date attribute.
  2. Select the attribute form (ID) on which to qualify from this attribute.
  3. Select the operator needed-in this case 'Exactly' (=).
  4. Set the qualification type to 'Custom'.
  5. Drag an attribute from the object browser into the text box next to the qualification type or enter the attribute name and its form according to the following format: attribute_name@form_name. In this case, enter 'Date@ID'. If the attriubte name has spaces, use the '' symbols to group the name. For example: @ID.

SQL GENERATION:
 
The report generates the following SQL:


select a22. AS CUSTOMER_ID,
 max(a23.) AS CUST_LAST_NAME,
 max(a23.) AS CUST_FIRST_NAME,
 a22. AS ORDER_ID,
 a21. AS DATE_ID,
 sum(a21.) as DOLLARSALES
from  a21,
  a22,
  a23
where a21. = a22. and 
 a22. = a23.
 and a21. = a21.
group by a22.,
 a22.,
 a21. 

The Strategy SQL Generation Engine finds the lookup tables and fact tables and performs a join between them based on the conditionality between the two attributes.
 
If there are no facts on the template that relate to both attributes and these attributes belong to different hierarchies, a Cartesian (cross) join is performed. In this case, the SQL Generation Engine must be instructed which table to use to relate both attributes via a relationship filter:

< ; (Date@ID = @ID) > {Order}

The Filter Details pane displays the table the SQL Engine uses to perform the attribute-to-attribute comparison.
 

ka04W000000OcUIQA0_0EM440000002GKV.gif

 
This report generates the following SQL:


select a31. AS ORDER_ID
from  a31
where (exists (select *
 from  r21
 where r21. = r21.
  and r21. = a31. )) 

This feature allows not only attribute-to-attribute comparisons, but many other complex comparisons. For more information regarding relationship filters, please refer to the Strategy Advanced Reporting Guide.


Comment

0 comments

Details

Knowledge Article

Published:

May 5, 2017

Last Updated:

May 5, 2017