Forum Discussion

Dave-ExpSC's avatar
Dave-ExpSC
Helper II
4 years ago

Retrieve data from a secondarily related table

I'm still learning. Fortunately I have this forums help! 

The ITEM tables has products in it. It is related to the ITEM MATERIAL tbl by ITEM ID. The ITEM MATERIAL table is related to the MATERIAL table by MATERIAL ID. I want to bring the NAME from the MATERIALS table into the ITEM table. Note that there may be multiple MATERIAL [Names] associated with a single Product (row) in the ITEMS tbl.  I can either bring all of the "related" material names into new columns for each product but preferably they could populate a single column and be comma delimited.

Hopefully I have provided enough infromation. Thank you.

6 Replies

  • TheoC's avatar
    TheoC
    Community Champion

    Hi Dave-ExpSC 

     

    You can try use the following:

     

    Formula =
    CALCULATE (
        FIRSTNONBLANK ( MATERIAL[name], 1 ),
        FILTER ( ALL ( MATERIAL ), Material[material_ID] = ITEM MATERIAL[material_id] ) )

     

    Hope this helps! 

     

    Theo

     

    • Dave-ExpSC's avatar
      Dave-ExpSC
      Helper II

      I can't quite make it work. I get this far and can not get the ITEM MATERIAL tbl to show --- do you see what the issue is? Thank you for your help.

       
      Materials Count = (FIRSTNONBLANK(MATERIAL[name], 1),
      FILTER( ALL(MATERIAL), MATERIAL[material_id] = ITEM MAT
       

       

      • TheoC's avatar
        TheoC
        Community Champion

        Hi Dave-ExpSC 

         

        Can you use the format that I have used in the original measure? The brackets and commas, etc, all need to match.

         

        Let me know how it goes and I can adjust if it doesn't work.

         

        Theo 🙂

         

         

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Dave-ExpSC ,

     

    You can try to change the relationship between the table ITEM MATERIAL and the table MATERIAL to the Both filtering direction, and use the Related() function to bring the column [Name] into the ITEM table.

    https://docs.microsoft.com/en-us/dax/related-function-dax

    https://docs.microsoft.com/en-us/power-bi/transform-model/desktop-create-and-manage-relationships#cross-filter-direction

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.