Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 485791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:26:15+00:00 2026-05-13T01:26:15+00:00

Proficient with SQL but new to MDX, I am having trouble getting my head

  • 0

Proficient with SQL but new to MDX, I am having trouble getting my head around this:

I have a fact table that contains snapshots of account balances monthly. I need to roll up the balances as a semi-additive measure – straight sum doesn’t work, obviously, for balances. However, I DO need to sum all the balances within EACH month, separately, by adding together the balances for all accounts, and so the “lastnonempty” notion isn’t working for me either. Example, if the facts look like this:

Date        AccountNo     Balance
2009-01-31  1111          $100
2009-01-31  2222          $100
2009-01-31  4444          $100
2009-01-31  5555          $100

2009-02-28  1111          $100
2009-02-28  2222          $200
2009-02-28  3333          $500
2009-02-28  5555          $50

etc.

And I have an account dimension that groups accounts into a major category / minor category / account hierarchy, I need output like this that sums the balances for each month across all accounts:

Month        Total
January 09   $400
February 09  $850

And by broken out by account type:

Month        Total
January 09   $400
  Type 1      $200
    1111       $100
    2222       $100
  Type 2     $200
February 09  $850
  Type 1     $300
  Type 2     $550

BUT, the balances should NOT sum across months, quarters or years, because it makes no sense, and they’d be counted twice. Any longer time interval should show the close of period:

Quarter    WRONG    Correct
Q1         $1250    $850   // should be the sum of balances for the *last* month in Q1
  Type 1   $500     $300
  Type 2   $759     $550

If I use the stock “lastnonempty” aggregation, I seem to get only the one, literal last account row for a month, not the sum of the account balances for the last month. It’s as if the total for the month is showing just the balance taken from one random account present in that month, and not the total. (I’m sure it’s not really random, probably is picking one based on storage order or something)

I’m sure I am just doing something simple, wrong…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T01:26:15+00:00Added an answer on May 13, 2026 at 1:26 am

    I think I solved this one: my source data having the balances was very sparse – there was a row only for non-zero balances, and NO rows for accounts when the balance is zero. That made everything screwy (imagine as inventory, where you have counts of parts, and those counts are often zero, but when they are 0 then the row is just missing from the fact table)

    I was able to create a view at the data source that would “add back in” all the additional rows, with zero balances, and after that the ClosingPeriod() function started working as expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 244k
  • Answers 244k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer On what grounds do you claim that it should be… May 13, 2026 at 8:03 am
  • Editorial Team
    Editorial Team added an answer When I explain things like this to non-programmers, I usually… May 13, 2026 at 8:03 am
  • Editorial Team
    Editorial Team added an answer You could set a tmpfs (or ramfs) mount with the… May 13, 2026 at 8:03 am

Related Questions

Bear in mind here, I am not an Access guru. I am proficient with
I started with Turbo Pascal 3, went to TP5, Bought TP6 called Borland the
While using Vim (at home and at work), I often find myself doing similar
could you point me to a good place to start with Oracle stored procedures

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.