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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Conditionally assign union in Dax tabular model

Hi Team,

 

I've created two variables with different conditions below. (T1 and T2  )

I need to do union based on some condition in ssas tabular not in power bi.

example: if(condition="no approve",union(T1,T2),otherwise will return only T1)

 

I tried below quey but error like: The expression specified in the query is not a valid table expression. Can you help me on this?

 

Query

DEFINE
VAR T1 =
SUMMARIZECOLUMNS (

sl[status],
sl[desc]

)

VAR T2 =
SUMMARIZECOLUMNS (
sp[SpStatus],
sp[desc]
FILTER (
sp,
sp[SpStatus]
IN { "no approve" })

)
VAR union_T1_T2 =
UNION ( T1, T2)

var gl=IF(VALUES(sp[SpStatus])="no approve",

union_T1_T2,

T1)

EVALUATE
gl

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

The IF function won't output tables, only single values.

 

However, since you already have a SpStatus filter inside the definition of T2, wouldn't what you're trying to do be the same as just union_T1_T2 since T2 is empty if the condition isn't met?

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

The IF function won't output tables, only single values.

 

However, since you already have a SpStatus filter inside the definition of T2, wouldn't what you're trying to do be the same as just union_T1_T2 since T2 is empty if the condition isn't met?

amitchandak
Super User
Super User

@Anonymous , Try like, if might not work

try like

union(T1,filter(T2,condition="no approve"))

 

or

union(T1,filter(T2,if(condition="no approve", true(), false() ))

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.