简体   繁体   中英

MDX count occurrences per hour over a time

Looking to get an MDX query for SSAS to get the average Report Executions per hour over any time frame. I"m working with a cube that has SSRS metadata.... and i want to get average Executions per hour.
I figured i have to count how many hours are involved.... as many reports are only run until 5 PM.... so i can't do a straight 24 hour timeframe.

i got something like this so far.... but it's CONSISTENTLY dividing by all hours.... Also i'm already tracking the total counts of executions....

here's the mdx i have... the calc is working, but it keeps dividing everything by 16 for a specific day ... ie.... for 12PM.... it divides by the total transactions by 16 hours.... but the transaction only occurred twice....between 12-1PM. so it should divide by 2.....

   WITH MEMBER [Measures].[Hour Count] AS
        sum(
                [Execution End Time].[24 Hour Time].[Hour 24].MEMBERS,
                IIF([Measures].[Report Execution Count] >= 1,1,0))
        MEMBER [Measures].[Average Exec Per Hour] AS
                ([Measures].[Report Execution Count]/[Measures].[Hour Count])

select
  {[Measures].[Hour Count]
, [Measures].[Report Execution Count] as ['Transaction Count']
, [Measures].[Average Exec Per Hour]}
on Columns
        ,[Execution End Time].[24 Hour Time].[Hour 24]  on Rows
from [BICC DM]
where  ([Execution End Date].[Calendar Dates].[Date Key].&[20160707])

Data extract

Change the definition of the first measure to below -

WITH MEMBER [Measures].[Hour Count] AS
IIF(
    ([Execution End Time].[24 Hour Time].CurrentMember,[Measures].[Report Execution Count])  >= 1,
    1,
    0
   )

The issue with your existing measure is the it is evaluating the value for a static set (ie [Execution End Time].[24 Hour Time].[Hour 24].MEMBERS ). I guess what you want to do is evaluate it for the current hour instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM