SOLVED

Power Pivot relations

%3CLINGO-SUB%20id%3D%22%5C%26quot%3Blingo-sub-3153836%5C%26quot%3B%22%20slang%3D%22%5C%26quot%3Ben-US%5C%26quot%3B%22%3EPower%20Pivot%20relations%26lt%3B%5C%2Flingo-sub%26gt%3B%3CLINGO-BODY%20id%3D%22%5C%26quot%3Blingo-body-3153836%5C%26quot%3B%22%20slang%3D%22%5C%26quot%3Ben-US%5C%26quot%3B%22%3E%3CP%3EThis%20is%20somehow%20related%20to%20my%20previous%20question%20%22%3CA%20href%3D%22%5C%26quot%3Bhttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fexcel%2Fbasic-power-pivot-question-why-does-the-relationship-quot-not%2Ftd-p%2F2649324%5C%26quot%3B%22%20target%3D%22%5C%26quot%3B_self%5C%26quot%3B%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EBasic%20Power%20Pivot%20question%20(why%20does%20the%20relationship%20%22not%20work%22)%22%26lt%3B%5C%2FA%26gt%3B%2C%20but%20I%20have%20a%20similar%20problem%20in%20a%20new%20file%20(see%20attached).%26lt%3B%5C%2FP%26gt%3B%3C%2FA%3E%3C%2FP%3E%3CP%3EI%20have%20a%20fact%20table%20%22ItemVendor%22%20and%20a%20dimension%20table%20%22CompDetailAll%22%2C%20with%20a%20shared%20field%20%22SKU%22.%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3EDimtable%20%22CompDetailAll%22%3A%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%5C%26quot%3Blia-inline-image-display-wrapper%22%20lia-image-align-inline%3D%22%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Fgxcuf89792%2F%5C%26quot%3Bhttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F347278i1C4615A890B526B8%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%5C%26quot%3B%22%20role%3D%22%5C%26quot%3Bbutton%5C%26quot%3B%22%20title%3D%22bartvana_1-1644577381329.png%22%20alt%3D%22%5C%26quot%3Bbartvana_1-1644577381329.png%5C%26quot%3B%22%20%2F%3E%26lt%3B%5C%2Fspan%26gt%3B%26lt%3B%5C%2FP%26gt%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EFact%20table%20%22ItemVendor%22%3A%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%5C%26quot%3Blia-inline-image-display-wrapper%22%20lia-image-align-inline%3D%22%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Fgxcuf89792%2F%5C%26quot%3Bhttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F347279i3EF547175121846F%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%5C%26quot%3B%22%20role%3D%22%5C%26quot%3Bbutton%5C%26quot%3B%22%20title%3D%22bartvana_2-1644577409009.png%22%20alt%3D%22%5C%26quot%3Bbartvana_2-1644577409009.png%5C%26quot%3B%22%20%2F%3E%26lt%3B%5C%2Fspan%26gt%3B%26lt%3B%5C%2FP%26gt%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3ERelation%3A%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%5C%26quot%3Blia-inline-image-display-wrapper%22%20lia-image-align-inline%3D%22%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Fgxcuf89792%2F%5C%26quot%3Bhttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F347277i4EC053DE4240B09C%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%5C%26quot%3B%22%20role%3D%22%5C%26quot%3Bbutton%5C%26quot%3B%22%20title%3D%22bartvana_0-1644577302520.png%22%20alt%3D%22%5C%26quot%3Bbartvana_0-1644577302520.png%5C%26quot%3B%22%20%2F%3E%26lt%3B%5C%2Fspan%26gt%3B%26lt%3B%5C%2FP%26gt%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3EWhen%20I%20make%20a%20pivot%20table%2C%20I%20can't%20get%20it%20right.%20If%20I%20grab%20the%20SKU%20from%20the%20dimtable%2C%20I%20get%20the%20following%20problem%3A%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%5C%26quot%3Blia-inline-image-display-wrapper%22%20lia-image-align-inline%3D%22%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Fgxcuf89792%2F%5C%26quot%3Bhttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F347281i51934E657F854A0E%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%5C%26quot%3B%22%20role%3D%22%5C%26quot%3Bbutton%5C%26quot%3B%22%20title%3D%22bartvana_3-1644577491538.png%22%20alt%3D%22%5C%26quot%3Bbartvana_3-1644577491538.png%5C%26quot%3B%22%20%2F%3E%26lt%3B%5C%2Fspan%26gt%3B%26lt%3B%5C%2FP%26gt%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EIf%20I%20grab%20the%20SKU%20from%20the%20fact%20table%2C%20I%20have%20the%20following%20problem%3A%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%5C%26quot%3Blia-inline-image-display-wrapper%22%20lia-image-align-inline%3D%22%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Fgxcuf89792%2F%5C%26quot%3Bhttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F347282i21307DE3E21E9973%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%5C%26quot%3B%22%20role%3D%22%5C%26quot%3Bbutton%5C%26quot%3B%22%20title%3D%22bartvana_4-1644577519999.png%22%20alt%3D%22%5C%26quot%3Bbartvana_4-1644577519999.png%5C%26quot%3B%22%20%2F%3E%26lt%3B%5C%2Fspan%26gt%3B%26lt%3B%5C%2FP%26gt%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3EI%20can%20solve%20this%20by%20looking%20up%20the%20dim%20values%20in%20the%20fact%20table%2C%20or%20vice%20versa%2C%20but%20what's%20the%20use%20of%20relations%20if%20I%20have%20to%20that%3F%20I'm%20a%20bit%20confused%20here...%26lt%3B%5C%2FP%26gt%3B%26lt%3B%5C%2Flingo-body%26gt%3B%3CLINGO-LABS%20id%3D%22%5C%26quot%3Blingo-labs-3153836%5C%26quot%3B%22%20slang%3D%22%5C%26quot%3Ben-US%5C%26quot%3B%22%3E%3CLINGO-LABEL%3EBI%20%26amp%3B%20Data%20Analysis%26lt%3B%5C%2Flingo-label%26gt%3B%3CLINGO-LABEL%3EPower%20BI%26lt%3B%5C%2Flingo-label%26gt%3B%26lt%3B%5C%2Flingo-labs%26gt%3B%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3C%2FLINGO-SUB%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3153836%22%20slang%3D%22en-US%22%3EPower%20Pivot%20relations%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3153836%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20is%20somehow%20related%20to%20my%20previous%20question%20%22%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fexcel%2Fbasic-power-pivot-question-why-does-the-relationship-quot-not%2Ftd-p%2F2649324%22%20target%3D%22_self%22%3EBasic%20Power%20Pivot%20question%20(why%20does%20the%20relationship%20%22not%20work%22)%22%3C%2FA%3E%2C%20but%20I%20have%20a%20similar%20problem%20in%20a%20new%20file%20(see%20attached).%3C%2FP%3E%3CP%3EI%20have%20a%20fact%20table%20%22ItemVendor%22%20and%20a%20dimension%20table%20%22CompDetailAll%22%2C%20with%20a%20shared%20field%20%22SKU%22.%3C%2FP%3E%3CP%3EDimtable%20%22CompDetailAll%22%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22bartvana_1-1644577381329.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F347278i1C4615A890B526B8%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22bartvana_1-1644577381329.png%22%20alt%3D%22bartvana_1-1644577381329.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EFact%20table%20%22ItemVendor%22%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22bartvana_2-1644577409009.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F347279i3EF547175121846F%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22bartvana_2-1644577409009.png%22%20alt%3D%22bartvana_2-1644577409009.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3ERelation%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22bartvana_0-1644577302520.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F347277i4EC053DE4240B09C%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22bartvana_0-1644577302520.png%22%20alt%3D%22bartvana_0-1644577302520.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20I%20make%20a%20pivot%20table%2C%20I%20can't%20get%20it%20right.%20If%20I%20grab%20the%20SKU%20from%20the%20dimtable%2C%20I%20get%20the%20following%20problem%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22bartvana_3-1644577491538.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F347281i51934E657F854A0E%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22bartvana_3-1644577491538.png%22%20alt%3D%22bartvana_3-1644577491538.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EIf%20I%20grab%20the%20SKU%20from%20the%20fact%20table%2C%20I%20have%20the%20following%20problem%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22bartvana_4-1644577519999.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F347282i21307DE3E21E9973%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22bartvana_4-1644577519999.png%22%20alt%3D%22bartvana_4-1644577519999.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20can%20solve%20this%20by%20looking%20up%20the%20dim%20values%20in%20the%20fact%20table%2C%20or%20vice%20versa%2C%20but%20what's%20the%20use%20of%20relations%20if%20I%20have%20to%20do%20that%3F%20I'm%20a%20bit%20confused%20here...%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3153836%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBI%20%26amp%3B%20Data%20Analysis%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPower%20BI%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Frequent Contributor

This is somehow related to my previous question "Basic Power Pivot question (why does the relationship "not work")", but I have a similar problem in a new file (see attached).

I have a fact table "ItemVendor" and a dimension table "CompDetailAll", with a shared field "SKU".

Dimtable "CompDetailAll":

bartvana_1-1644577381329.png

Fact table "ItemVendor":

bartvana_2-1644577409009.png

Relation:

bartvana_0-1644577302520.png

 

When I make a pivot table, I can't get it right. If I grab the SKU from the dimtable, I get the following problem:

bartvana_3-1644577491538.png

If I grab the SKU from the fact table, I have the following problem:

bartvana_4-1644577519999.png

 

I can solve this by looking up the dim values in the fact table, or vice versa, but what's the use of relations if I have to do that? I'm a bit confused here...

6 Replies
best response confirmed by bartvana (Frequent Contributor)
Solution

@bartvana All credit should go to @Sergei Baklan , for the solution in the thread you linked. I just took the same approach to create the following measure that I called "DA":

=CALCULATE(
   SUM(tCompDetailAll[StDevAvg]),
   TREATAS (
      VALUES(tItemVendor[SKU]),
      tCompDetailAll[SKU]
   )
)

 

Riny_van_Eekelen_0-1644581337997.png

 

@bartvana 

Your desired result is

image.png

Actually you aggregate both by SKU and Supplier, even if Supplier is not shown here.

As variant you may create two measures

DelayDays:=SUM(tItemVendor[DelTermDays])

and

StDev:=IF( ISBLANK([DelayDays]) , blank(),  SUM(tCompDetailAll[StDevAvg]) )

They give

image.png

As a comment, always hide field on many side of relationships, it helps to avoid some errors

image.png

 

 

@Sergei Baklan @Riny_van_Eekelen Thank you for your answers.

It still isn't really clear to me however, but maybe this is outside of the scope of this forum. In the TREATAS reference page it says (and Sergei also said this in answer to my other question "Best for use when a relationship does not exist between the tables." But I have a relationship between the tables. What is the use then of such a relationship if I still have to make measures with the same relationship defined in them again?

@bartvana 

That's since we try to receive result using many-to-one relationship, which is not supported in Excel directly. Same result as with TREATAS() we may receive using physical relationship, but with measure using CROSSFILTER()

StDevR :=
CALCULATE (
    SUM ( tCompDetailAll[StDevAvg] ),
    CROSSFILTER ( tItemVendor[SKU], tCompDetailAll[SKU], BOTH )
)

In this case we have no SupplierID in PivotTable but DelTermDays are not aggregated, they are used as labels

image.png

@Sergei Baklan OK, so for everything that's many-to-one you need to write a measure, that's more or less it, right?

That's good to know, I thought that by simply creating the physical relationship the magic was going to happen by itself :).

@bartvana 

That's in Excel. In Power BI Desktop you may define that in properties. Another story is that such kind of relationships are not good from performance point of view, better to avoid where possible.