RSS
 

Posts Tagged ‘filter’

PHP Analaytics – Filter data on user input

31 Jan

Just today I have got a question about the chance to add prompts to the wordpress page in order to filter dinamically a particular view.

Due to lack of time I didn’t develop any administration interface to add input boxes, but it’s possible to achieve it by using the PHP Analytics’ variables.

1. A simple single value filter

First of all we create one or more variables that will dynamically change the where condition that refers to the query we want to be affected by the user input.

Then we modify the query itself to pick up values from the variable(s).

A PHP Analytics variable is initialized with a GET or a POST action, so in order to pass the user input to the variable we have to create an HTML form that contains an HTML input component with the same name of the variable (see the example below):

<form method="post">
<select name="country">
      <option value="France">France</option>      <option value="Germany">Germany</option>      <option value="Greece">Greece</option>      <option value="Italy">Italy</option>      <option value="Portugal">Portugal</option>      <option value="Spain">Spain</option>      <option value="UK">UK</option></select>
    <input id="button" name="button" type="submit" value="Submit" />
</form>

Then we just have to add to our WordPress page/post the HTML code above and the view it belongs to (see the example below).

COUNTRY USERS
Italy 653

Read the rest of this entry »

 

OBIEE Tips #1: Calculate the first day of the current month in answers

03 Nov

1 – Introduction

This post explains how to calculate the first day of the current month using OBIEE functions; this tip is useful when you need to build reports that shows current month data by default.
The steps below can be used also to calculate the first date of a given month.

2 – Calculate the first day of the current month

The OBIEE expression to calculate the first day of the current month is the following:

TIMESTAMPADD(SQL_TSI_DAY, -1*(DAYOFMONTH(CURRENT_DATE )-1) , CURRENT_DATE )

Let’s try to understand it.

CURRENT_DATE: OBIEE function that returns the current system date
DAYOFMONTH(<<expression>>): return the number of the passed day within a month (e.g. if <<expression>> equals 05/12/2010, the function returns 5)
TIMESTAMPADD(<<interval>>, <<expression>>, <<timestamp>>): adds a specified number of intervals to a specified timestamp, and returns a single timestamp; valid values for <<interval>> are: SQL_TSI_SECOND, SQL_TSI_MINUTE, SQL_TSI_HOUR, SQL_TSI_DAY, SQL_TSI_WEEK, SQL_TSI_MONTH, SQL_TSI_QUARTER, SQL_TSI_YEAR

Read the rest of this entry »