Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi everybody,
I'm facing a problem regarding the IF/SWITCH function because i'm using DirectQuery.
I created a measure and tried using IF/SWITCH but it doesn't allow me to do any comparison with my table. Then I thought instead a measure I'll use a column, but since I have to do a calculation with a measure that comes from a different table, it gives me the error: A calculated column or RLS expression on a DirectQuery table cannot reference tables from a different data source.
I have no more ideas and I would like to know your thoughts on this.
Thanks,
Marta
Hi @martaredondo ,
Please share some sample data and your expected output. Then we will understand more clearly about your requirement.
With direct query mode, if we create a calculated column, the mode will change to mixed mode. It means the original data is still with DQ mode. And the new column is with import mode. For this part, you could reference the document to learn more.
If your tables are related, you can use RELATED() function to do it. Something like this:
column = IF(RELATED(table1[column1]) = "A", table2[Column2], table2[column3])
@martaredondo , what is your if statement. If it across two tables then you can not do like
if(Table[A]=Table2[A],,)
You can try like if(Max(Table[A])=max(Table2[A]),,)
You have to make sure you force some row context using summarize or values.
Refer how common row context use for date diff
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 39 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 133 | |
| 88 | |
| 85 | |
| 68 | |
| 64 |