Friday, May 27, 2016

Using KPI's from a Datasource

If you've tried to create KPI's using data sourced from a SQL Server database (or probably any data source for that matter) you may have run into some issues. Here are some tips:-

If you're using date-based information, and you want your KPI to be the most recent value, then if your select statement is 'order by my_datetime desc' then the aggregation should be First; and if it's 'order by my_datetime asc' then the aggregation should be Last.

If you want the mini-graph visualization to have the most recent value to the right then you should choose 'order by my_datetime asc' and have the aggregation as 'Last'. And you need to set the aggregation as Last for both the Value and the Status fields.

To test this, create a sample dataset with an ascending date column:-

select '2016-06-20' as my_date,1 as kpi_value, 1 kip_status
union all
select '2016-06-21',2,1
union all
select '2016-06-22',3,0
union all
select '2016-06-23',4,-1
order by my_date asc

Create the KPI and set the aggregation for the Values and Status to "Last":-


Pull the Value, Status and Trend from the same dataset and create the KPI:-