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! Request now

Reply
bbelman
New Member

In DAX formula, Conditionally Concatenate value from another table

I am trying to use a DAX forumla to create a new table that requires me to reference existing data (which will be the rows in the table) and I also need to reference other existing data in order to conditionally concatenate a value to one of the columns. In SQL, I would do it like this.

 

CASE WHEN [SecondaryTable].[Rate] != '1.0'
THEN CONCAT ([PrimaryTable].[Summary], ' - ', [SecondaryTable].[Description])
ELSE [PrimaryTable].[Summary]
END
AS [Summary]

 

I have tried to recreate the table using SELECTCOLUMNS but I cannot reference the secondary table inside the function as it is out of scope. Is there a way to accomplish this in DAX? Both tables habe been imported into Power BI Desktop

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

@bbelman You can create a new table with the following measure:

Table 2 =
VAR __table =
    ADDCOLUMNS (
        'Primary Table',
        "combine",
            IF (
                RELATED ( 'Secondary Table'[rate] ) <> 1,
                'Primary Table'[summary] & " - " & RELATED ( 'Secondary Table'[descripton] ),
                'Primary Table'[summary]
            )
    )
RETURN
    SELECTCOLUMNS ( __table, "id", [id], "summary", [combine] )

v-jingzhang_0-1602036197985.png

View solution in original post

5 REPLIES 5
v-jingzhang
Community Support
Community Support

@bbelman You can create a new table with the following measure:

Table 2 =
VAR __table =
    ADDCOLUMNS (
        'Primary Table',
        "combine",
            IF (
                RELATED ( 'Secondary Table'[rate] ) <> 1,
                'Primary Table'[summary] & " - " & RELATED ( 'Secondary Table'[descripton] ),
                'Primary Table'[summary]
            )
    )
RETURN
    SELECTCOLUMNS ( __table, "id", [id], "summary", [combine] )

v-jingzhang_0-1602036197985.png

Worked perfectly. Thank you! I expect the other posted solution provided will also work but performing the action in a measure as opposed to a calcualted column provides better proformance by keeping the dataset lean.

lbendlin
Super User
Super User

show sample data and expected outcome. This should be doable.

Primary Table

idsummarybilled_at
1Reformat Hard Drive1
2Add new users to directory1
3Add new users to directory2

 

Secondary Table

iddescriptonrate
1regular1.0
2overtime1.5

 

Output Table

idsummary
1Reformat Hard Drive
2Add new users to directory
3Add new users to directory - overtime

 

Note: The "billed_at" column in the primary table here is achieved in my use case through JOINs in SQL and RELATIONSHIPS in Power BI and is not directly included in the table. 

Join the tables via [Billed at]<-[id]

 

then have a calculated column in the 'Primary Table'

 

Summary Combined = [summary] & if(related('Secondary Table'[description])<>"regular"," - " & related('Secondary Table'[description]),"")

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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!

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.

Top Solution Authors