Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Count Only Correctly Associated Keys

I have a table where I am trying to only count the rows that are correctly associated. I have two dimension tables, that link to my fact table.

 

Key Table

NameKey
Fruit1
Vegetable2

 

Subcategory Key

Food TypeFood Subcategory TypeFood Subcategory KeyFood Type Key
FruitApple11
VegetableBrocolli22
FruitBanana31
VegetableCarrot42

 

Customer #Food SubcategoryFood CategoryWas Eaten?Food Category KeyFood Subcategory Key
11111AppleFruitY11
11111BrocolliFruitY12
11111BrocolliVegetableY22

 

Is there a way to construct a DAX measure where each of the dim tables is connected to the fact table (and each other), that would only count when Brocolli is listed as a vegetable and not a fruit? The data I'm working with has multiple subcategory types, so would be curious if the measure would only count the row if the keys were correct and lined up in the dimension table.

2 Replies

  • hi Anonymous 

    Try to get the [Food Category Key] and [Food Subcategory Key] columns in your fact table by merging with the Subcategoty dimtable based on two columns: [Food Category] and [Food SubCategory].

  • Anonymous's avatar
    Anonymous
    Not applicable

    FreemanZ  I am not sure I am following, the two key tables are linked and are also linked to the master fact table