Link Fact and Dim using 2 IDs based on a conditional logic

Abhay Sudhakaran 101 Reputation points
2021-03-22T03:25:28.663+00:00

Objective: Use 2 IDs to create conditional relationship b/w fact and dim table

The conditional logic should be:

  • Use F_ID if exists.
  • Also if F_ID is NULL then use I_ID to link records

79849-image.png

Azure Analysis Services
Azure Analysis Services
An Azure service that provides an enterprise-grade analytics engine.
479 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Samara Soucy - MSFT 5,141 Reputation points
    2021-03-22T23:30:49.237+00:00

    This can be achieved by adding a calculated column to both tables that will create a composite key based on whether or not F_ID is null or not. Where this would not necessarily work if Rec_No 5 in your dimension table had a value in F_ID, so you may need to handle that case.

    The DAX for the composite key is:
    Comp_Key = IF(ISBLANK([F_ID]) || [F_ID] == "NULL", [I_ID], [F_ID])

    And the resulting table would look something like this:

    80346-2021-03-22-19-29-29-window.png

    By adding that column to both tables you'll be able to create the relationship you want.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.