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
Anonymous
Not applicable

CALCULATE on each row entry in another table's column

I'm trying to find the smallest value of [comment_id] in the table in the attached screenshot given a [target_id]. In the example, let's say I am using the [target_id] value of 3366. The [type] value is also 2. In the table 'Ticket Comments Relations', we can see that the [target_id] value of 3366 gives us two matching rows as highlighted. Their [comment_id] values are 59714 and 59719. 

Screenshot 2020-07-13 at 12.04.14.png

My DAX formula for a column in another table is 

CALCULATE(MIN('Ticket Comments Relations'[comment_id]); FILTER('Ticket Comments Relations'; 'Ticket Comments Relations'[target_id] = 3366 && 'Ticket Comments Relations'[type] = 2))

This gives me the correct number of 59714, the lesser of the two [comment_id] values. However, this column is hard-coded as using 3366 as the value for all the rows. There exists two tables with a one-to-many relationship to each other ('Tickets' to 'Ticket Comments Relations'). 'Tickets' contains the unique value of 3366, as a previous example, and 'Ticket Comments Relations' might have many instances of 3366. 

How can I make my formula use the unique value in 'Ticket's instead of the hard-coded 3366?

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Assume the other table ticket has target id we can create a new column in ticket like

New Column in ricket =
mix(filter('Ticket Comments Relations','Ticket Comments Relations'[target_id] = ticket[target_id] &&  'Ticket Comments Relations'[type] = 2),'Ticket Comments Relations'[comment_id])

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , Assume the other table ticket has target id we can create a new column in ticket like

New Column in ricket =
mix(filter('Ticket Comments Relations','Ticket Comments Relations'[target_id] = ticket[target_id] &&  'Ticket Comments Relations'[type] = 2),'Ticket Comments Relations'[comment_id])

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.