1

So this question goes off the one here

I've been trying to do a similar count measure and I did the suggested solution but it's still running.... and it's been more than 30 minutes with no results, while without that it runs in under a minute. So am I missing something? Any guidance would help. Here is my query:

WITH 
    MEMBER [Measures].[IteractionCount] AS 
    NONEMPTY
    (
        FILTER
        (
            ([DimInteraction].[InteractionId].[ALL].Children,
            [Measures].[Impression Count]),
            [DimInteraction].[Interaction State].&[Enabled]
        )
    ).count

SELECT 
(
    {[Measures].[IteractionCount],
    [Measures].[Impression Count]}
)
ON COLUMNS,
(   

    ([DimCampaign].[CampaignId].[CampaignId].MEMBERS,
     [DimCampaign].[Campaign Name].[Campaign Name].MEMBERS, 
     [DimCampaign].[Owner].[Owner].MEMBERS)
    ,[DimDate].[date].[date].MEMBERS
)
ON ROWS
FROM 
(
    SELECT 
    (
       {[DimDate].[date].&[2020-05-06T00:00:00] : [DimDate].[date].&[2020-05-27T00:00:00]}
    )
    ON COLUMNS 
    FROM [Model]
)
WHERE
(
        {[DimCampaign].[EndDate].&[2020-05-27T00:00:00]:NULL}, 
        [DimCampaign].[Campaign State].&[Active], 
        {[DimInteraction].[End Date].&[2020-05-27T00:00:00]:NULL}//,
        //[DimInteraction].[Interaction State].&[Enabled]
)     

I don't know if FILTER is affecting it in any way but I tried it with and without and it still runs forever. I do need it specifically filtered to [DimInteraction].[Interaction State].&[Enabled]. I have also tried to instead filter to that option in the WHERE clause but no luck

Any suggestions to optimize this would be greatly appreciated! thanks!

UPDATE: I end up using this query to load data into a python dataframe. Here is my code for that. I used this script for connecting and loading the data. I had to make some edits to it though to use windows authentication.

ssas_api._load_assemblies() #this uses Windows Authentication
conn = ssas_api.set_conn_string(server='server name',db_name='db name')

df = ssas_api.get_DAX(connection_string=conn, dax_string=query))

The dax_string parameter is what accepts the dax or mdx query to pull from the cube.

1 Answer 1

0

Please try this optimization:


WITH 
    MEMBER [Measures].[IteractionCount] AS 
    SUM
    (
        [DimInteraction].[InteractionId].[InteractionId].Members
         * [DimInteraction].[Interaction State].&[Enabled],
         IIF(
           IsEmpty([Measures].[Impression Count]),
           Null,
           1
         )
    )

SELECT 
(
    {[Measures].[IteractionCount],
    [Measures].[Impression Count]}
)
ON COLUMNS,
(   

    ([DimCampaign].[CampaignId].[CampaignId].MEMBERS,
     [DimCampaign].[Campaign Name].[Campaign Name].MEMBERS, 
     [DimCampaign].[Owner].[Owner].MEMBERS)
    ,[DimDate].[date].[date].MEMBERS
)
PROPERTIES MEMBER_CAPTION
ON ROWS
FROM 
(
    SELECT 
    (
       {[DimDate].[date].&[2020-05-06T00:00:00] : [DimDate].[date].&[2020-05-27T00:00:00]}
    )
    ON COLUMNS 
    FROM [Model]
)
WHERE
(
        {[DimCampaign].[EndDate].&[2020-05-27T00:00:00]:NULL}, 
        [DimCampaign].[Campaign State].&[Active], 
        {[DimInteraction].[End Date].&[2020-05-27T00:00:00]:NULL}//,
        //[DimInteraction].[Interaction State].&[Enabled]
)     
CELL PROPERTIES VALUE

If that doesn’t perform well the please describe the number of rows returned by your query when you comment out IteractionCount (sic) from the columns axis. And please describe how many unique InteractionId values you have.

2
  • Thanks! It works great in ssms and runs in like 2-3 min. but I'm trying to load this data into a pandas dataframe. I have all that I need in place to load it in but on the python side it is still taking forever. Would you know why there is this delay? Jun 2, 2020 at 0:06
  • @LubochkaMarchenko I updated my answer by adding the dimension properties and cell properties clauses. That may reduce the amount of data being returned over the wire. That python library is probably not an ideal implementation as it reads the entire resultset into memory in a DataTable object. Then it reads through it and converts to a DataFrame. But I don’t have a good alternative other than to look for an implementation that uses AdomdDataReader instead of AdomdDataAdapter Jun 2, 2020 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.