+ Reply to Thread
Results 1 to 9 of 9

Relationship issues in Datamodel and DAX Measure

  1. #1
    Forum Contributor
    Join Date
    10-14-2020
    Location
    Shanghai
    MS-Off Ver
    O365
    Posts
    162

    Relationship issues in Datamodel and DAX Measure

    Hi,

    I do have issues with relationship in the datamodel to show the proper data in my analysis.
    The attached sample file should show my problem.

    I do have 7 Tables loaded into PQ and the Datamodel.
    DIMCustomer: List of Customer and partnumber (=Finish Goods)
    DIMSupplier: List of Supplier part number and the names
    DIMDate: just simple years
    SalesVolume: for each Customer Finish Good and year the sales volume
    Sales Price: price per year for each Finish good
    BOM: For each Customer Finish good a supplier partumber including the amount used for the finish good.
    BOM Price: Price for each Supplier part for each year

    BOM usage means e.g. to build Partnumber Customer 1 I need 5 S1 Part, 2 S2 Part and 1 S3 parts

    I created the relationships but get the wrong results im my worksheet PIVOT.


    What do I want:
    The Pivot table should be able to show per my row selection the Salesvolumen, the used BOM Parts and quantity of them, the cost of the BOM parts,...

    I created one example in the sheet PIVOT (Yellow area)


    What is my problem:
    The Relationship is not working. after selecting the cust.Partnumber I see all Suppliers and all Partnumber of the supplier. Therefore the volumes are also wrong

    Another issue is the DAX to calculate the measure. E.g. for my selection in the pivot, multiply the USAGE with the Volume(=measure BOM Units), then take this measure and multiply the result with the price




    I hope someone can help me out a bit


    thanks
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    10-14-2020
    Location
    Shanghai
    MS-Off Ver
    O365
    Posts
    162

    Re: Relationship issues in Datamodel and DAX Measure

    Hi

    i modified a bit and I do come closer. Had to modify one direction of the relationship.

    Now the DM and pivot out of it is showing the right values, but the filter of the relations are not passed through. I do see the BOM units and usage but the filter is not used for some tables. I see rows which i do not want to see (red rows in pivot chart), the ones i want to see are the green ones.


    Any ideas why the selection from DIMSupplier is not passed through (indirect via PartnumberCustomer to Salesvolume and Salesprice)?

    thanks a lot
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by hansolu; 02-11-2022 at 01:37 AM. Reason: upload the correct file

  3. #3
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Relationship issues in Datamodel and DAX Measure

    Hi,

    Quote Originally Posted by hansolu View Post
    I see rows which i do not want to see (red rows in pivot chart), the ones i want to see are the green ones.
    I can't see any red or green rows in either of your files?

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  4. #4
    Forum Contributor
    Join Date
    10-14-2020
    Location
    Shanghai
    MS-Off Ver
    O365
    Posts
    162

    Re: Relationship issues in Datamodel and DAX Measure

    Hi
    sorry, uploaded the initial file in my second post, just now changed to the correct file'
    thanks

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,026

    Re: Relationship issues in Datamodel and DAX Measure

    Filters propagate from the 1 side to the many side, so any DimSupplier filter can only go to BOM and BOMPrice based on your diagram.
    Everyone who confuses correlation and causation ends up dead.

  6. #6
    Forum Contributor
    Join Date
    10-14-2020
    Location
    Shanghai
    MS-Off Ver
    O365
    Posts
    162

    Re: Relationship issues in Datamodel and DAX Measure

    Hi, so the filter only propagate to the many side, not further down?

    Does this mean I need to merge the tables in PQ to get back to a star scheme for my relations? I was trying to use the formula:
    CustSalesPrice=RELATED(SalesVolumes[Volume]) to create a calculated column in the DimSupplier but doesnt work

    Any ideas how I can move on?
    thanks

  7. #7
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Relationship issues in Datamodel and DAX Measure

    Yes, I believe you're on the right lines. Have a look at this link:

    https://www.sqlbi.com/blog/marco/200...in-powerpivot/

    in particular the paragraph which begins:

    "Moreover, if you want to analyze which are the accounts accessible by each customer, dicing Customers and Accounts doesn’t filter out the accounts that don’t belong to the analyzed Customer. In the following screenshot you can see that all the accounts are present with the total amount of the accounts belonging to analyzed Customer."

    Regards

  8. #8
    Forum Contributor
    Join Date
    10-14-2020
    Location
    Shanghai
    MS-Off Ver
    O365
    Posts
    162

    Re: Relationship issues in Datamodel and DAX Measure

    hi, thanks for the reply,

    I had a look and still, i am confused how to create the related formulas. I tried to do but get an error for mine
    CustSalesPrice=RELATED(SalesVolumes[Volume])
    This formula is invalid or incomplete: 'The column 'SalesVolumes[Volume]' either doesn't exist or doesn't have a relationship to any table available in the current context.'.

    I will have a look over the weekend hopefully

    thanks

  9. #9
    Forum Contributor
    Join Date
    10-14-2020
    Location
    Shanghai
    MS-Off Ver
    O365
    Posts
    162

    Re: Relationship issues in Datamodel and DAX Measure

    Hi
    took longer than expected but found a solution

    I added a measure:
    Please Login or Register  to view this content.
    My understanding now is that calculate passes the filter from table BOM into the salesvolume table.


    By doing so also for the other dimensions, I get my desired pivot table.

    I will now go and integrate this solution into my real data and verify. But looks good so far.

    thanks
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Pivot calculated field vs Datamodel measure
    By hansolu in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 11-16-2021, 10:08 PM
  2. Sort filtered and summarized table in Measure (Datamodel)
    By hansolu in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 09-30-2021, 10:00 PM
  3. [SOLVED] Averagex measure in datamodel
    By hansolu in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 09-13-2021, 01:12 AM
  4. Many to Many Pivot Relationship Issues
    By willstein818 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 01-07-2021, 06:26 AM
  5. [SOLVED] CubeValue Direct from DataModel
    By ptmuldoon in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 12-28-2020, 02:04 PM
  6. [SOLVED] DAX Measure result differs due to relationship between tables
    By ThxAlot in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 05-10-2020, 07:20 AM
  7. Pivot Table: Grand Total different measure from Column measure
    By chinneywow in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 08-07-2019, 06:22 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1