Different summations using SQL with TI

Post Reply
A.Pete
Posts: 38
Joined: Fri May 18, 2012 7:06 pm
OLAP Product: TM1 , transformer
Version: 9.5 + 10.1 + 10.2 + 10.2.1
Excel Version: 2010 + 2008
Location: Sweden

Different summations using SQL with TI

Post by A.Pete »

Hi there

im using a simple SQL to load my cube with data:

select * from [/b] this will take around 1-1½ hours to load (around 10 million rows) and ive mapped out the variables i want to use in the cube. The problem is that this gave me the wrong total in the cube... so I rewrote the SQL to this. [b]Select A, B, C, sum(Amount), sum(quantity) from [Table] group by A, B, C[/b] and then I got the correct summations plus it took 15 minutes to build the cube... So my question/wondering would be if anyone else has discovered this? Is it a known issue or is [b]Select * from [Table][/b] the incorrect syntax for ODBC connections? /Peter
User avatar
qml
MVP
Posts: 1098
Joined: Mon Feb 01, 2010 1:01 pm
OLAP Product: TM1 / Planning Analytics
Version: 2.0.9 and all previous
Excel Version: 2007 - 2016
Location: London, UK, Europe

Re: Different summations using SQL with TI

Post by qml »

My guess is that your TI code is not accumulating values, but overwriting them, so if you have more than one row with the same details you will end up with just the last row loaded for that line, instead of all of them being added up. This is something that can be fixed either in the SQL query (like you did), or in the TI code itself (by using CellPutN(Value+CellGetN()) logic).
Kamil Arendt
Duncan P
MVP
Posts: 600
Joined: Wed Aug 17, 2011 1:19 pm
OLAP Product: TM1
Version: 9.5.2 10.1 10.2
Excel Version: 2003 2007
Location: York, UK

Re: Different summations using SQL with TI

Post by Duncan P »

I am not sure that I would rely on the order of the columns in a select * from to remain static. If a new column was added to the table or view you might get others shifted across and then they wouldn't match up with your variables any more. I would always specify my columns explicitly.
Post Reply