Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Slavi
Frequent Visitor

See if value from Table A exists in table B via measure

Hello PBI comminuty,

 

I am trying to find out whether a values from Column A Table A exist in Column B table B. 

I have manged to do this via calculated columns but because I am now using PBI datasets I cannot use calculated columns, only measures.

How can I do this?

Sample of my data from the two tables:

Table A:

Project NameDurationOwnerDescription
ABC2 daysMichael-----
ABC3 daysOwen-----
ABB1 dayRichard-----
ABB2 daysSilvia-----
ABD1 dayNeal-----

 

Table B:

Project NameLocationBuilding
ABCGermany1A
ABBGermany1B

 

Based on the data above the measure should bring back a number 1 for projects ABC and ABB because they appear in both Table A and table B, and 0 for project ABD because it is missing in Table B. 

 

Thank you!

1 ACCEPTED SOLUTION
latimeria
Solution Specialist
Solution Specialist

@Slavi ,

 

If you only need to check whether there is a value, you can use the sql  equivalent of exist, not isempty

 

Exist in TableB =
VAR CurrentProject = SELECTEDVALUE(TableA[Project Name] )
RETURN
INT( CALCULATE( NOT ISEMPTY(TableB), TableB[Project Name] = CurrentProject ) )
 
latimeria_0-1654522323280.png

 

View solution in original post

5 REPLIES 5
latimeria
Solution Specialist
Solution Specialist

@Slavi ,

 

If you only need to check whether there is a value, you can use the sql  equivalent of exist, not isempty

 

Exist in TableB =
VAR CurrentProject = SELECTEDVALUE(TableA[Project Name] )
RETURN
INT( CALCULATE( NOT ISEMPTY(TableB), TableB[Project Name] = CurrentProject ) )
 
latimeria_0-1654522323280.png

 

Thank you for the reply @latimeria , indeed it works for my case

Slavi
Frequent Visitor

Hello @AlB and thanks for your response,

 

Unfortunatelly, in my case the Tranform Data option that the person used in the video is disabled and I cannot create the local model.

Anonymous
Not applicable

Hello

Try this

JamesFr06_0-1654519730724.png

Mesure =
VAR proj =
SELECTEDVALUE ( 'Table A'[Project Name] )
VAR _step1 =
FILTER (
SUMMARIZE ( 'Table B', 'Table B'[Project Name] ),
'Table B'[Project Name] = proj
)
VAR result =
IF ( COUNTROWS ( _step1 ) > 0, COUNTROWS ( _step1 ), 0 )
RETURN
result

AlB
Super User
Super User

Hi @Slavi 

HAve you tried adding a local model to crete the calculated column?  Check this out:

https://youtu.be/g-nRxDVt3To?t=166

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.