Forum Discussion

SNik's avatar
SNik
Helper I
10 years ago
Solved

Table Relations and Blanks

Hi I have 3 tables that have a 1 to many relation with each other   Product-----> catalog -----> 2015Data (fact) the relations are sets with no errore when for the first 2 tables i am using a Sl...
  • Greg_Deckler's avatar
    10 years ago

    SNik - As I recall from previous posts and greggyb might be able to help you because I have seen him post on this before, the blank values in slicers are caused when you have some relationships that don't match up correctly. For example, you have a Product specified as part of the Catalog that is not in your Products table. That's the likely cause of your blanks in your slicers, something along those lines. Power BI has a way of making problematic data obvious like that.

  • greggyb's avatar
    greggyb
    10 years ago

    Greg_Deckler has got it. So, I just had another post in another thread with a very different topic that is nevertheless relevant to this discussion. That post where I describe the dictionary associated with each field in a table is where we can find the source of this phantom blank.

     

    As Greg_Deckler said, when you have a row in the fact (many side of the 1:N) table that does not have an associated key in the dimension (one side of the 1:N), the storage engine will implicitly create a phantom-blank row. This phantom-blank becomes the lookup key for every row in the fact that doesn't have an appopriate lookup key in the dimension. This shows up in a few places. It becomes a display value, as you've seen in slicers. When you do a COUNTROWS( VALUES( 'Dimension'[Key] ) ), you'll see one more row than you expect. The row is the phantom-blank. You'll also see it in ALL(). This is because those functions reference not the values in the table rows, but in the column dictionary. DISTINCT() behaves identically to VALUES() in nearly every way, except it will omit the phantom-blank.

     

    So how do we get rid of it? We can either add an explicit row to the dimension for all possible values in the fact table, or we can alter the fact table to exclude those rows, or transform the key field on all rows that don't have a match in the dimension to point to an alternate 'Unknown' key in the dimension.

     

    Once you've altered the dimension or the fact or both, you should be able to refresh the entire model and the phantom-blank should be gone.

     

    This behavior differs from a foreign key in SQL or a relationship in Multidimensional, which both require that everything in the fact table have a matching row in the dimension table. Tabular is more permissive and lets you do things like this, and implicitly puts the pieces in place to support it.