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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.