Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

An SSAS head-scratcher..... Expand / Collapse
Author
Message
Posted Monday, October 21, 2013 9:16 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Today @ 8:36 AM
Points: 588, Visits: 1,157
Hi Folks,
I'm getting some weird behavior in SSAS and I'm posting to see if it has happened to anyone else or if anyone knows how to resolve it.

So I have two time differences that need to be averaged out and I go about it like so:
1) In the source data there is a DATEDIFF(Second, StartDateTime, EndDateTime) calculation. This is working as expected and is used to create a hidden measure in my cube.
2) I then get an average from the above by doing [Measures].[Seconds]/[Measures].[Some Number].
3) As the client wants to see an HH:MM string of this average time I have the following calculated member:
IIF([Measures].[Respond Sec] = NULL, NULL,
-- Hours
IIF ([Measures].[Respond Sec] < 60*60,
'00',
IIF([Measures].[Respond Sec] < 36000,
'0' + CStr(Int([Measures].[Respond Sec]/60/60)),
CStr(Int([Measures].[Respond Sec]/60/60)))

) + ':'
-- Minutes
+
IIF ([Measures].[Respond Sec] < 60, '00',
IIF ([Measures].[Respond Sec] < 600,
CStr(Int(
([Measures].[Respond Sec] - Int([Measures].[Respond Sec]/60/60)*60*60)
/60))
,
RIGHT('0' + CStr(Int(
([Measures].[Respond Sec] - Int([Measures].[Respond Sec]/60/60)*60*60)
/60))
, 2)
)
)
)


Like I mentioned before I am doing this for 2 things (response and fix times). The response times work perfectly. The fix times are what is weird. It appears that they work......sometimes. For some reason for two of the years of data the year total is a massive negative number (this is the original calc and not the HH:MM bit as above, that just returns 00:00). If you drill into the date hierarchy though there are no negatives and it appears to be working fine?????

I've looked through the source data and there are no negative values. I've played around with the DATEDIFF at source by CASEing it as NULL if there is no fix datetime (I think this is the default behavior of DATEDIFF anyway but I wanted to be sure) but no. I even tried casting it as a BIGINT just in case that was the issue, still no.
There is no difference between the way I get the data for response times except it uses a different datetime column, so why is one working and the other not?

Does anyone have any ideas please???

Thanks in advance





I'm on LinkedIn
Post #1506713
Posted Wednesday, October 23, 2013 10:38 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, June 18, 2014 3:28 AM
Points: 1,044, Visits: 1,839
What is the need to create a formatted measure in the cube. If you have data available as seconds you can easily cast the value as HH:MM:SS in the SSRS report.

Regards/Raunak
Now a member of Linkedin

Please visit the all new Performance Point Forum
Please visit the all new Data Mining and Business Analytics Forum
Post #1507875
Posted Thursday, October 24, 2013 3:01 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Today @ 8:36 AM
Points: 588, Visits: 1,157
Thanks for your comment, although that's not really the issue. The reason I am doing it in MDX is that the client needs to analyze the data dynamically and won't be using SSRS for static reporting, otherwise yes I would do it in SSRS. I included the MDX above for completeness.

The actual issue is that there is an integer value which is correct at source but when processed in SSAS at certain hierarchical levels (always 2 out of however many for some reason) is showing as a large negative value before any of the MDX above is applied.

If you could share your thoughts on that I would be grateful





I'm on LinkedIn
Post #1507928
Posted Thursday, October 24, 2013 10:01 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Today @ 8:36 AM
Points: 588, Visits: 1,157
I have received an answer on the MSDN forums (word, Greg Galloway! ). It would seem that this problem is caused by overloading an INT data type. I changed it all to BIGINT (in the source and the measure itself) and it fixed it. You learn something new every day




I'm on LinkedIn
Post #1508136
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse