Forum Discussion

IvanS's avatar
IvanS
Icon for Helper V rankHelper V
4 years ago
Solved

LOOKUPVALUE not working without relationship

Hi guys,

 

I would need your help with LOOKUPVALUE function. I have pretty complex model so I cannot have active relationships between tables DIM_Products and DIM_Locations.

This is how the tables look:

DIM_Products

- Product ID

- Location ID

 

DIM_Locations

- Location ID

- Location Name

 

I need to populate Location Name into DIM_Products table. I tried to duplicate table and create new DIM_Location to Product and create relationships - then both RELATED and LOOKUPVALUE functions worked well.

LOOKUPVALUE('DIM_Locations to Products'[Location Name], 'DIM_Locations to Products'[Location_Id], DIM_Products[Location_Id])
RELATED('DIM_Locations to Products'[Location Name])

 

Due to size of model, I cannot accept to create such dummy tables, and therefore I removed duplicated table and remove relationship (respectively to keep inactive relationship) and rewrite the function as:

LOOKUPVALUE('DIM_Locations'[Location Name], 'DIM_Locations'[Location_Id], DIM_Products[Location_Id])

 

However this function is retrieving blanks values. As far as I know, LOOKUPVALUE does not require to have relationship between tables - any ideas what can be the root cause here?

 

Thank you
IvanS

 

4 Replies

  • bcdobbs's avatar
    bcdobbs
    Icon for Community Champion rankCommunity Champion

    Are the id columns the same data type in both tables?

    • IvanS's avatar
      IvanS
      Icon for Helper V rankHelper V

      Thanks a lot! The I change type to number and then back to text and suddenly it is working! 🙂

  • Hi Ivan

     

    Your data model is wrong

    Dimension should not be referencing Dimension

     

    Try this classic star schema ...

     

    DIM_Products

    - Product ID

    - Product Name
    - Product Category

    - Product Brand

     

    DIM_Locations

    - Location ID

    - Location Name
    - Location Country


    Fact_Stock

    - Product ID

    - Location ID

    - Qty


    Then addrelationships

    DIM_Products[Product ID] 1:M Fact_Stock[Product ID]
    DIM_Locations[Location ID] 1:M Fact_Stock[Location ID]

     

    Thanks for reaching out for help.

    I put in a lot of effort to help you, now please quickly help me by giving kudos.

    Remeber we are unpaid volunteers and here to coach you with Power BI and DAX skills and techniques, not do the users job for them. So please click the thumbs up and accept as solution button. 

    If you give someone a fish then you only give them one meal, but if you teach them how to fish then they can feed themselves and teach others for a lifetime.  I prefer to teach members on this forum techniques rather give full solutions and do their job. You can then adapt the technique for your solution, learn some DAX skills for next time and soon become a Power BI Super User like me. 

    One question per ticket please. If you need to extend your request then please raise a new ticket.

    You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

    • IvanS's avatar
      IvanS
      Icon for Helper V rankHelper V

      Hi speedramps ,

       

      this model is pretty complicated as I have FACT_Tasks with "RelatedToID" field. And under this field it can be DIM_Locations, DIM_Deals and DIM_Products. And all of the DIM tables have Location name. And I need to get that into FACT_Tasks.

       

      However, the question is still why LOOKUPVALUE is not able to find matching location without having active relationship.