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

Use column references in the filter of CALCULATE

Hello

 

I want to do a calculation:

 

CALCULATE(COUNTROWS(Table1),Table1[Column2]=Table2[Column1])

 

However it says the expression can only contain one column. Is there any workaround for this?

 

For example Table1:

1, A

2, B

3, C

 

Table2:

A

B

C

 

I want to count the rows of Table1 using as criteria Table1[Column2]=Table2[Column1] instead of hardcoding the criteria as Table1[Column2]="A" etc

 

Thanks

5 REPLIES 5
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Is this problem solved?


If it is solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.


If not, please let me know.

 


Best Regards,
Icey

Anonymous
Not applicable

Hi, unfortunately it is not solved. I get multiple errors of different types.

amitchandak
Super User
Super User

@Anonymous , In case they join on the same column you do not need that

else try

CALCULATE(COUNTROWS(Table1),filter(Table1,Table1[Column2]=max(Table2[Column1])))

CALCULATE(COUNTROWS(Table1),filter(Table1,Table1[Column2]=related(Table2[Column1])))


Row context need to forced using values or summarize when you check data above the match level

 

CALCULATE(COUNTROWS(Table1),filter(Table1,Table1[Column2]=max(Table2[Column1])),values(Table1[Column2]))

 

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
ryan_mayu
Super User
Super User

@Anonymous 

 

I changed your sample data because all the three letters can be found in both tables.

1.PNG2.PNG

Then I will find how many letters in table 1 can be found in table 2

Measure 2 = 
VAR TBL=ADDCOLUMNS(SUMMARIZE(Table1,Table1[index],Table1[letter]),"MATCH",LOOKUPVALUE('Table2'[LETTER],Table2[LETTER],'Table1'[letter]))
VAR tbl2=FILTER(TBL,[MATCH]<>"")
return COUNTROWS(tbl2)

3.PNG

hope this is helpful.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Tahreem24
Super User
Super User

@Anonymous ,

Try the below DAX:

Column = CALCULATE(COUNTROWS(Table1),FILTER(ALL(Table2),Table2[Name] = RELATED(Table1[Name])))
It will give you 3 in output.
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

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.