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
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
Employee
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
Employee
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
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.

Top Solution Authors