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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
hassanh_2
New Member

DAX Function to Create a Column Based on condition / filter in another column

Hello,

Im trying to create a new column that returns a value from another table based on condition / filter.

 

As you see I have the following 2 tables. I want to create a new column in Table 2, in that column I need to return the "Sales Person" of the first Log_ID.

 

(Note: in my relationship model there is an Inactive relationship by "Acct Nr.") 

 

hassanh_2_0-1669711772320.png

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @hassanh_2 
Please try

NewColumn =
MAXX (
    TOPN (
        1,
        CALCULATETABLE ( Table2, USERELATIONSHIP ( Table1[Acct Nr], Table2[Acct Nr] ) ),
        Table2[Log_ID], ASC
    ),
    Table2[Sales Person]
)

View solution in original post

5 REPLIES 5
hassanh_2
New Member

Is there a way though to create it as a Column so I can use it as a Parameter dimension in other visuals?

 

@hassanh_2 

What is the direction of the relationship between the two tables? Can you provide a screenshot?

hassanh_2
New Member

I created the same function as a measure and it worked. Thank you!

tamerj1
Super User
Super User

Hi @hassanh_2 
Please try

NewColumn =
MAXX (
    TOPN (
        1,
        CALCULATETABLE ( Table2, USERELATIONSHIP ( Table1[Acct Nr], Table2[Acct Nr] ) ),
        Table2[Log_ID], ASC
    ),
    Table2[Sales Person]
)

Hi, Thanks!

It seems you switched the Table Numbers but I tried both ways and the new column didnt return any value!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.