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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Use Measure to Count How Many Times Value Appears in Another Column

Hi All,

I'm trying to see how often the values in one column appear in another column in a different table, and I need the count to change based on filters.  The below calculated column does the job for a static count:

 

=COUNTROWS(FILTER(Table 1, Table 1[Column A] = Table 2[Column A])))

 

Whenever I try to drop the formula into a measure, I get an error that a single value for the column cannot be determined.  I'd appreciate any help anyone can give.

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi  @Anonymous 

You could use this formula:

Measure222 = COUNTROWS(FILTER('Table 1', 'Table 1'[Column A] in VALUES('Table 2'[Column A])))

 

Regards,

Lin

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
v-lili6-msft
Community Support
Community Support

hi  @Anonymous 

You could use this formula:

Measure222 = COUNTROWS(FILTER('Table 1', 'Table 1'[Column A] in VALUES('Table 2'[Column A])))

 

Regards,

Lin

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I attempted to use this, however it did not bring back the total amount of times the value appeard in the second table. 

PaulDBrown
Community Champion
Community Champion

@Anonymous
Or as an alternative (no need to create a new table) you can try:
Measure = CALCULATE(COUNTROWS(table 2), TREATAS(VALUES(table 1 [column A]), table 2 [column A]))

 

and include the field "table 1 [column A]" in your table.

 

measure sol.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






PaulDBrown
Community Champion
Community Champion

1)Create a new table for unique values in table 1:
Values Table 1 = VALUES(table1[column A])

2) in the modeling pane, create a relationship between the new table and table 2 (if you need to do other calculations involving both tables, also create a relatiosnhip with table 1)

Model.JPG

 


3) new measure
Counting Table 2 values = COUNTROWS(table 2)
4) create a table visual with column from “Values Table 1” and the measure [Counting Table 2 values]

Model results.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






amitchandak
Super User
Super User

Try like

calculate(COUNTROWS(FILTER(Table 1, Table 1[Column A] = firstnonbank(Table 2[Column A],blank())),values(Table 1[Column A] ))
Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

@amitchandak

I got an error that there were too many arguments for COUNTROWS, so I added an extra parenthesis after BLANK().  It's not returning anything.

Try like

calculate(COUNTROWS(FILTER(Table 1, Table 1[Column A] = firstnonbank(Table 2[Column A],blank()))),values(Table 1[Column A] ))
Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.