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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
ruhor
Frequent Visitor

Filling in Calculated Colmn Values if an Entry Exists in Another Table

I have two DB tables which I imported into Power BI. One is a table of rental properties named "property" and the other is a table of metered utilities named utilityprops. I added a new column to the property table and named it "metered". I would like to write a DAX statement that matches propid from the Property table with a utilid id in the utilityprops table, if it finds an entry for a metered utility in utilityprops table it would return a 1 in the column for [Metered], if it can't find an entry for the utilid it would put a 0 in the [Metered] column. Properties that have metered utilities will almost always have more than one utilid entry in utilityprops for a given propid, since most of the time, when water is metered so is sewer. This is what the property table looks like:

 

propid	name		shortname	street	city	state	zip......	metered (new column)
1	oakwood
5	pleasantville
8	riverside
10	needle rock
22	foggy ridge
23	green park
24	cripple creek
25	royal oaks
37	riverbend
55	bates hotel

And this is what utilityprops table looks like:

 

 

utilid		propid
218		1	
219		1	
222		5
223		5
225		8
226		8
228		22
229		22
230		23
231		23
232		24
233		24
236		25
237		25
245		55

This is what I am aiming for after the calculated column is populated in the property table:

 

 

propid	name		shortname	street	city	state	zip......	metered
1	oakwood									1
5	pleasantville								1
8	riverside								1
10	needle rock								0
22	foggy ridge								1
23	green park								1
24	cripple creek								1
25	royal oaks								1
37	riverbend								0
55	bates hotel								1

I setup a relationship between the property table and the utilityprops table using the propid. Would it be possible to do a simple If statement like:

 

metered = IF (
    ISBLANK('ruhor_views utilityprops'[utilid]),
    0,
    1
)


Thanks!

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Make sure that utilityprops is related to properties (many to one) and then use this for your metered column:

metered = IF(COUNTX(RELATEDTABLE(utilityprops),'utilityprops'[propid])>0,1,0)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

Make sure that utilityprops is related to properties (many to one) and then use this for your metered column:

metered = IF(COUNTX(RELATEDTABLE(utilityprops),'utilityprops'[propid])>0,1,0)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Works perfect, thanks.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.