SSAS MDX - How to add an aggregation SUM to MDX Query WITH clause?

I'm using this WITH clause to create my column fields, I need to summarize 3 Flag columns by STORE.

with        
            Member [Measures].[Status Complete] as
                  (left([Measures].[Completed Flag]/[Measures].[Assigned Flag],1))
            Member [Measures].[Status In Progress] as
                          (left([Measures].[Inprogress Flag]/[Measures].[Inprogress Flag],1))
                  Member [Measures].[Status Past Due] as
                          (left([Measures].[Pastdue Flag]/[Measures].[Pastdue Flag],1))

Can someone help me with the SYNTAX on how to SUM each of these columns? I will be using the columns in a select below,but I need to understand how to create the SUM. I'm assuming I create the SUM in the WITH Clause.
LVL 17
MIKESoftware Solutions ConsultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PortletPaulEE Topic AdvisorCommented:
It looks like you could do all 3 columns using CROSS APPLY

select CA.X, CA.Y. CA.Z
FROM Measures
CROSS APPLY (
    SELECT
        (left([Measures].[Completed Flag]/[Measures].[Assigned Flag],1)) AS X
    ,  (left([Measures].[Inprogress Flag]/[Measures].[Inprogress Flag],1)) AS Y
   ,   (left([Measures].[Pastdue Flag]/[Measures].[Pastdue Flag],1)) AS Z
 ) as CA

or as a "derived table"


select
*
FROM (
    SELECT
      *
    ,  (left([Measures].[Completed Flag]/[Measures].[Assigned Flag],1)) AS X
    ,  (left([Measures].[Inprogress Flag]/[Measures].[Inprogress Flag],1)) AS Y
   ,   (left([Measures].[Pastdue Flag]/[Measures].[Pastdue Flag],1)) AS Z
   FROM Measures
 ) as derived
PortletPaulEE Topic AdvisorCommented:
Sorry, re-read the question you wanted more for the sums.

SELECT
      Store
    , SUM (left([Measures].[Completed Flag]/[Measures].[Assigned Flag],1)) AS X
    , SUM (left([Measures].[Inprogress Flag]/[Measures].[Inprogress Flag],1)) AS Y
   ,  SUM (left([Measures].[Pastdue Flag]/[Measures].[Pastdue Flag],1)) AS Z
FROM Measures
GROUP BY
      Store
ORDER BY
      Store

For this you don't need WITH, or CROSS APPLY, or a derived table

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.