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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Calculate Function not working for referencing columns from different table using Direct Query

Hi,

 

I have created the following calculated column in a PBI report using import query.
Column = CALCULATE(COUNTBLANK(Phone), FILTER(Family, Student[FamilyId] = Family[FamilyId])

 

where as the tables are as follows 

Student IDFamilyID
1F1
2F2
3F1
4F3
5F2

 

FamilyIDMemberPhone
F1Dad016-456-89876
F1Mom 
F1Uncle676-876-98543
F2Dad 
F2Mom412-562-88765
F3Dad416-542-86758

 

So Ideally, the output column would be 

 

Student IDcolumn
11
21
31
40
51

 

But, Now I have to create this report using DirectQuery connection. But when I try the same query, I'm not able to use the Calculate functions in the calculated column.

 

Can you pls help me with a solution for this issue?

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Download my PBI file from here.  I have used measures only.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
AlexisOlson
Super User
Super User

Direct Query has modeling limitations. See this documentation.

 

In particular, "Calculated columns are limited to being intra-row, as in, they can only refer to values of other columns of the same table, without the use of any aggregate functions.So, you definitely can't refer to another table in a calculated column using DirectQuery.

 

Not all hope is lost though. You can often achieve the same goal using measures instead of calculated columns. It's not clear what your purpose for this column is though so it's hard to suggest a workaround.

Anonymous
Not applicable

Hi Alexis,

 

Thank you for helping me out.. But I'm not sure whether measures will help me with my current issues.

 

I have two tables.. a student table and a familymember table.

 

The student table has the details of individual students like StudentID, Name, year, class, FamilyID etc., where StudentID is the Primary key.

 

Student IDFamilyID
1F1
2F2
3F3
4F4
5

F1

 

 

In the Family table, the details of the family members of the students will be stored such as FamilyID, Family member name, relation, Phone No & email ID etc. But the Family ID is not a primary key as multiple family members belonging to the same family will be tagged to the same ID.

 

FamilyID  Member  Phone
F1Dad016-456-89876
F1Mom 
F1Uncle676-876-98543
F2Dad 
F2Mom412-562-88765
F3Dad416-542-86758
F4Dad414-546-88678

 

I needed to find the no of students for whom any of the family member's Phone no was missing. In the above example, Students 1 &5 belonging to same family F1 have Mom's Phone no missing and Student 2 belonging to family F2 has Dad's phone no missing.

 

In the import mode, I created a calculated column to identify the Pupils for whom the family member's were missing phone no information using the following query, 

 

Column = CALCULATE(COUNTBLANK(Phone), FILTER(Family, Student[FamilyId] = Family[FamilyId]))

 

which would give me the following calculated column in the student table,

 

 

Student IDFamilyIDColumn
1F11
2F21
3F3 
4F4 
5

F1

1

 

Then i used a measure to count the no of pupils having column values using a COUNT function on 'Column' which would give me the result 3.

 

But now, I need to change the connection to DirectQuery because of which, the calculated column could not be created and I'm stuck.

 

Could you suggest me with an alternative workaround?

 

Pls let me know if you need any additional information.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.