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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
elponce
Frequent Visitor

Making a calculation by using 2 columns from different tables

Hello!!

 

I have the 2 sample tables below. I am trying to perform a calculation by using "DATEDIFF" function between 'Table 1'[Date Event Enter] and 'Table 2'[Date Action Started]. There is a relationship (Many to 1) between both tables using "Event ID" ("Event ID" for Table 1 has unique values) and both tables have over 30 columns that are not shown below. Table 2 does not have the same number of rows as Table 1.  

 

2 Tables.JPG

 

In Power BI, I can use the relationship established between both Tables and come up with the Table below. However, I do not know if there a way to make the calculation by using the data from this table created in Power BI. Ahy help is appreciated. Thank you for your time in advanced!

 

Final Table.JPG

 

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @elponce,

 

If above created table is a table visual, it is not possible to make calculations by using the data from it. If this created table is a calculated table or a merged table in Query Editor, you can use data from it.

 

In your scenario, since there existing a one to many relationship between Table 1 and Table 2, you can calculate the difference between two dates via creating a calculated column in Table 2.

Datediff = DATEDIFF(RELATED('Table 1'[Date Event]),'Table 2'[Date Action Started],DAY)

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @elponce,

 

If above created table is a table visual, it is not possible to make calculations by using the data from it. If this created table is a calculated table or a merged table in Query Editor, you can use data from it.

 

In your scenario, since there existing a one to many relationship between Table 1 and Table 2, you can calculate the difference between two dates via creating a calculated column in Table 2.

Datediff = DATEDIFF(RELATED('Table 1'[Date Event]),'Table 2'[Date Action Started],DAY)

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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