Suggestions for looking up dimensions at different levels using DAX...

Matty

Well-known Member
Joined
Feb 17, 2007
Messages
3,717
Hi Team,

Looking for a bit of advice as to how I could do the following in the most efficient way...

Fact table as follows:

Hierarchy Level 1Hierarchy Level 2Hierarchy Level 3Hierarchy Level 4Sales
#B1##
10​
##C1#
5​
###D1
20​
#B2##
5​
A1###
15​
##C4#
25​
###D2
10​

Dimension table as follows:

Hierarchy Level 1HL1 DescriptionHierarchy Level 2HL2 DescriptionHierarchy Level 3HL3 DescriptionHierarchy Level 4HL4 Description
A1USB1NorthC1North EastD1Shop 1
A1USB1NorthC1North EastD2Shop 2
A1USB1NorthC2North WestD3Shop 3
A1USB2SouthC3South EastD4Shop 4
A1USB2SouthC3South EastD5Shop 5
A1USB2SouthC3South EastD6Shop 6
A1USB2SouthC4South WestD7Shop 7

There is a relationship between the fact table and dimension table on the field 'Hierarchy Level 4', which is the lowest (most granular) level in the dimension table. The problem I have is that my fact table does not necessarily have Hierarchy Level 4 populated for each record, meaning I can't use this relationship for looking up anything in this scenario.

Here's what I want things to look like (note that descriptions are populated even in the absence of a Hierarchy Level 4):

HL1 Desc.HL2 Desc.HL3 Desc.HL4 Desc.Sales
USNorth##
10​
USNorthNorth East#
5​
USNorthNorth EastShop 1
20​
USSouth##
5​
US###
15​
USSouthSouth West#
25​
USSouthSouth WestShop 7
10​

Just wondering how others would tackle this problem?

Cheers,

Matty
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi,

Just to follow up on the above.

I have checked the real data again to ensure the above held in all situations. Actually, things *aren't* quite as complicated as I'd painted above!

The fact table is actually as follows:

Hierarchy Level 1Hierarchy Level 2Hierarchy Level 3Hierarchy Level 4Sales
A1B1##
10​
A1B1C1#
5​
A1B1C1D1
20​
A1B2##
5​
A1###
15​
A1B2C4#
25​
A1B1C1D2
10​

So, my join (relationship) to the dimension table (via Hierarchy Level 4) works fine if the fact table contains data at this granularity, but if it doesn't, the relationship does not work. I can create additional dimension tables for each of the higher hierarchy levels (where Hierarchy Level 4 is missing), but this doesn't seem like the best solution as it means users have to go to different dimension tables to get the dimension they need.

The ideal situation would be one dimension table that is able to join to the fact table at different levels depending on the level the given record is maintained at, but I can't think of a way to get this to work.

Any suggestions most welcome.

Cheers,

Matty
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,792
Members
449,048
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top