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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
RajMalhotra1984
Frequent Visitor

CUSTOM COLOUMN BASED ON TWO TABLES IN POWER BI

Hi I have a similar situation but no solution-

 

I have 1324 equipment numbers in table 1 all are unique values.

Then I have 1174 equipment number in table 2 all are unique values.

 

These equipment numbers are connected in the relation table.

 

Table 2 has Hours of work in a coloumn for each equipment.

 

What I intend to do is create a custom coloumn in table 1 where I can bring the hours of work for each equipment from table 1 and then where ever we don't have hours available in table 2 (1324-1174 = 150 equipments will have no hours as they don't exist in table 2). I want the custom coloumns to show 0 hours for these 150 equipments. Can you help.

1 REPLY 1
HassanAshas
Helper V
Helper V

Can you share sample Data from both these tables? and an expected output of the custom column you want in Table 1? 

From what I understood, you have two columns like these, 
 
Table 1
HassanAshas_0-1678456990734.png

 

Table 2

HassanAshas_1-1678457002157.png

 

 

Now you want the Hours from Table_2 to be transferred to the Table_1. 

 

There are two ways you can accomplish this,

 

First: If the tables are related (that is, you have a relation between them in your Data Model), then you can simply use the following DAX for your Custom Column in Table 1, 

 

 

 

Hours = RELATED(Table_2[Hours])

 

 

 

If you want "0" instead of BLANK, then use this, 

 

 

Hours = 
var __Hours = RELATED(Table_2[Hours])

RETURN 
    IF(
        ISBLANK(__Hours), 
        0, 
        __Hours
    )

 

 

 

Second Solution: If your tables are not related, then you can use LookUpValue (for this however, the Equipment_ID must be unique)

 

 

 

Hours = 

var __Hours = LOOKUPVALUE(Table_2[Hours], Table_2[Equipment_ID], Table_1[Equipment_ID])

RETURN 
    IF(
        ISBLANK(__Hours), 
        0, 
        __Hours
    )

 

 

This will give you the final output in Table_1 like this, 

 

HassanAshas_2-1678457334397.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.