Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

lookup values from another table

Hi, experts, I have two tables, dimension table and fact table, I created a filter use column from dimension table, but fact table may not exist some values in dimension table, and I need to make sure all the values from the fiters selected has relevant data, do you have any ideas?

My idea is that creat a measure in the dimension table, when the value from fact table exist in dimension table, then return 1, else 0, and apply this measure to the filter, but the measure crteated is not work.

here is the sample data and expected result:

dimsention table

region

A

B
C

fact table

regiondata
Aadaf
Cfadfa

expected result:

regionmeasure
A1
B0
C1

I created mesure like this: 

measure=

VAR _fact=MAX('fact'[region])

VAR _dim=MAX('dim'[region])
RETURN IF(_fact=_dim,1,0)
but the measure did not work
do you know how to how to make this measure correct or any other ideas on make the slicer show only relevant data?
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

     

    (1) We can create a calculated column.

    Column = IF('Fact Table'[region]=RELATED('Dimension table'[region]),1,0)

    (2)We can create a measure. 

    Measure = IF(SELECTEDVALUE('Fact Table'[Column])==BLANK(),0,1)

    (3) Then the result is as follows.

    Best Regards,

    Neeko Tang

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

7 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    Please find the below solution.

    Column = IF(Dim[Region]=RELATED('Fact'[REgion]),1,0)

     

    Best Regards,
    Shreya

    Appreciate with a Kudos!! (Click the Thumbs Up Button)
    Did I answer your question? Mark my post as a solution!

    • Anonymous's avatar
      Anonymous
      Not applicable

      I did not get the result use this column, there is  aloway an error with RELATED function,
      maybe because the data is imported?

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) My test data is the same as yours.

    (2) We can create a measure. 

    Measure = IF(LOOKUPVALUE('dimsention table'[region],'fact table'[region],MAX('dimsention table'[region])) ==BLANK(),0,1)

    (3) Then the result is as follows.

     

    Best Regards,

    Neeko Tang

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks, the sample data maybe too simple and some problems might hidden.

      If I add a row of data in fact table {C, aaa}, and the required relationship is 1-n, there would be an error, and I tried many times with this method

      here is the fact table and relationship, and relevant error:

      fact table added one record:

      relationship:

      error:

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

         

        (1) We can create a calculated column.

        Column = IF('Fact Table'[region]=RELATED('Dimension table'[region]),1,0)

        (2)We can create a measure. 

        Measure = IF(SELECTEDVALUE('Fact Table'[Column])==BLANK(),0,1)

        (3) Then the result is as follows.

        Best Regards,

        Neeko Tang

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