Forum Discussion
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
| region | data |
| A | adaf |
| C | fadfa |
expected result:
| region | measure |
| A | 1 |
| B | 0 |
| C | 1 |
I created mesure like this:
measure=
VAR _fact=MAX('fact'[region])
- Anonymous3 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
- AnonymousNot applicable
Hi Anonymous ,
Please find the below solution.
Column = IF(Dim[Region]=RELATED('Fact'[REgion]),1,0)Best Regards,
ShreyaAppreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!- AnonymousNot applicable
I did not get the result use this column, there is aloway an error with RELATED function,
maybe because the data is imported?
- AnonymousNot 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.
- AnonymousNot 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:
- AnonymousNot 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.