Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


An SSAS head-scratcher.....


An SSAS head-scratcher.....

Author
Message
PB_BI
PB_BI
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1291 Visits: 2404
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
Raunak Jhawar
Raunak Jhawar
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1095 Visits: 1944
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
PB_BI
PB_BI
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1291 Visits: 2404
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
PB_BI
PB_BI
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1291 Visits: 2404
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search