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

  • SEARCH
  • Home
  • 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 8360981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:35:50+00:00 2026-06-09T11:35:50+00:00

I’m in the process of designing the fact table for a data cube, and

  • 0

I’m in the process of designing the fact table for a data cube, and I have a measure which I don’t really know how to correctly aggregate. The following SQL code will create a small sample fact table and dimension table:

create table FactTable (
    ID      int,
    Color   int,
    Flag    int)

insert into FactTable (ID, Color, Flag) values (1, 'RED',   1)
insert into FactTable (ID, Color, Flag) values (1, 'WHITE', 0)
insert into FactTable (ID, Color, Flag) values (1, 'BLUE',  1)
insert into FactTable (ID, Color, Flag) values (2, 'RED',   0)
insert into FactTable (ID, Color, Flag) values (2, 'WHITE', 0)
insert into FactTable (ID, Color, Flag) values (2, 'BLUE',  1)
insert into FactTable (ID, Color, Flag) values (3, 'RED',   1)
insert into FactTable (ID, Color, Flag) values (3, 'WHITE', 1)
insert into FactTable (ID, Color, Flag) values (3, 'BLUE',  1)

create table ColorDim (
    CID     int, 
    Color  int)

insert into ColorDim (CID, Color) values (1, 'RED')
insert into ColorDim (CID, Color) values (2, 'WHITE')
insert into ColorDim (CID, Color) values (3, 'BLUE')

FactTable and ColorDim are joined on FactTable.Color = ColorDim.Color. In the cube, there should be a measure called ‘Patriotic’ which counts object IDs including the colors red, white, or blue (at least one of the colors). The desired output is as follows:

  • When browsing the cube, if the user pulls in the Patriotic measure (pulling no dimensions), the total shown should be 2, since there are 2 IDs (namely, 1 and 3) which include at least one of the three colors. Notice that ID 1 should contribute 1 to the total Patriotic value, even though it has two of the colors.
  • If the user browses the Patriotic measure by the Color dimension, they should see a table like the following. Note that the the ID 1 contributes 1 to the RED count and 1 to the BLUE count.

    +——–+———–+
    | Color | Patriotic |
    +——–+———–+
    | RED | 2 |
    | WHITE | 1 |
    | BLUE | 2 |
    +——–+———–+

(I tried to create a table using this web app, but the spacing doesn’t appear to be correct. Hopefully it’s readable enough to understand.)

I’m sure this is a very basic cube design situation, but I haven’t worked with cubes much before, and the measures I’ve used are usually simple SUMs of columns, or products of SUMs of columns, etc. Any help would be much appreciated.

(If it’s relevant, I’m running the SQL queries which build the fact/dimension tables in MS SQL Server 2008, and I’ll be designing the cube itself in MS Visual Studio 2008.)

  • 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-06-09T11:35:52+00:00Added an answer on June 9, 2026 at 11:35 am

    I finally figured it out. First, I added one row per ID to the fact table containing pre-aggregated data for that ID, so the fact table becomes:

    create table FactTable (
        ID      int,
        Color   int,
        Flag    int)
    
    insert into FactTable (ID, Color, Flag) values (1, 'RED',   1)
    insert into FactTable (ID, Color, Flag) values (1, 'WHITE', 0)
    insert into FactTable (ID, Color, Flag) values (1, 'BLUE',  1)
    insert into FactTable (ID, Color, Flag) values (1, 'PATRIOTIC',  1)
    insert into FactTable (ID, Color, Flag) values (2, 'RED',   0)
    insert into FactTable (ID, Color, Flag) values (2, 'WHITE', 0)
    insert into FactTable (ID, Color, Flag) values (2, 'BLUE',  1)
    insert into FactTable (ID, Color, Flag) values (2, 'PATRIOTIC',  1)
    insert into FactTable (ID, Color, Flag) values (3, 'RED',   1)
    insert into FactTable (ID, Color, Flag) values (3, 'WHITE', 1)
    insert into FactTable (ID, Color, Flag) values (3, 'BLUE',  1)
    insert into FactTable (ID, Color, Flag) values (3, 'PATRIOTIC',  1)
    

    Similarly, add a row to the color dimension table:

    create table ColorDim (
        CID     int, 
        Color  int)
    
    insert into ColorDim (CID, Color) values (1, 'RED')
    insert into ColorDim (CID, Color) values (2, 'WHITE')
    insert into ColorDim (CID, Color) values (3, 'BLUE')
    insert into ColorDim (CID, Color) values (4, 'PATRIOTIC')
    

    Then, in MS Visual Studio, edit the DefaultMember property of the Color attribute in the Color Dimension as:

    [Color Dimension].[ColorDim].&[PATRIOTIC]
    

    The DefaultMember property tells MS Visual Studio that rows of the fact table which have Color ‘PATRIOTIC’ are already aggregates of the other rows with the same ID and other Color values.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't

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.