Forum Discussion
Lookup value from one table from another
- Anonymous9 years ago
Hi Anonymous, sounds to me like you have selected "Add Measure" instead of "Add Column"?
Just check that you have used "Add Column" and done so in the table that will hold the CID Flag. In this case we are adding it to the CID Table.
CID Flag = IF( IFERROR( LOOKUPVALUE( 'CID Table'[CID], 'CID Table'[CID], 'Large Table'[CID] ), 0 ) = 0, 0, 1 )
Make that a column in your large table. You might need to rename the tables names i've used, but hope you get the idea.
Thanks a lot for the solution. And, it has definitely solved part of my issue.
I forgot to add another problem to it.
So, the counts calculated by the 'CID Flag' is also counting the duplicates since there are rows with same CID values in the larger table. How should I make sure that the Flag only counts the distinct rows from the larger table?
Thanks in advance.
- Anonymous9 years agoNot applicable
Try the same formula, except do it from the 'CID Table' to the 'Large Table' instead (in reverse). Lookup works on multiple rows, as long as each row would return the same value.
- Anonymous9 years agoNot applicable
I tried to replace the arguments and put it as :
CID Flag = IF( IFERROR( LOOKUPVALUE( 'Large Table'[CID], 'Large Table'[CID], 'CID Table'[CID]), 0 ) = 0, 0, 1 )
But, this is not working as the LOOKUPVALUE function is not allowing me to use 'CID Table'[CID] as the thrid argument at all. I can only see the columns of the Large Table for the third argument.
However, it is running when the previous query was used :
CID Flag = IF( IFERROR( LOOKUPVALUE( 'CID Table'[CID], 'CID Table'[CID], 'Large Table'[CID] ), 0 ) = 0, 0, 1 )
Could you please assist me here?
- Anonymous9 years agoNot applicable
Also, it seem the third argument needs to be a single value so, when I try using a column of another table, its just showing me the option to choose another measure as the third argument.
- v-caliao-msft9 years ago
Microsoft Employee
Anonymous,
I asume the large table have the sample data
Now you need to count the distinct value for the CIDs that have CID Flag=1, right?
If that is the case, please try to create a measure using the DAX below.
Measure = CALCULATE(DISTINCTCOUNT(Table3[CID]),FILTER(Table3,Table3[CID flag]=1))Regards,
Charlie Liao
- Anonymous9 years agoNot applicable
Thanks Charlie. I could get the distinct counts using your logic.