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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
liyucao
Microsoft Employee
Microsoft Employee

How to calculate the row count based on the other table

I have 2 tables. One is risks. It has RiskId and ServiceId. Another table is RiskId and JobId, the RiskId can occur multiple times in table2. I want to use ServiceId as slicer and display the RiskId and the count of occurence in table 2. 

measure =
var _sum = CALCULATE(
    COUNTROWS(table_2)
)
RETURN
_sum
 
It can only show the risks that occur in table 2, I want to show all risks with the select service Id no matter if it exists in table2. And if it does not exist in table 2, the number shows 0. How to write the measure?
1 ACCEPTED SOLUTION

Hi @liyucao,

I'm attaching a pbix file with the my solution.
The final result should be this:

_AAndrade_0-1716401135791.png

 







Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




View solution in original post

11 REPLIES 11
_AAndrade
Super User
Super User

Hi @liyucao,

I'm assuming that your measure is compute the right numbers when the RiskID exists in table 2. Take this in mind, to shows 0 when RiskID it's not exist in table 2 I only adjust the return to this:

var _sum = CALCULATE(
    COUNTROWS(table_2)
)
RETURN
IF(
  ISBLANK(_sum),
  0,
  _sum
)




Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




If so, the slicer will not take affect, it will show all risks

If you can provide a simple pbix or pictures of what you have now and the desired output,I could be more helpful.





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




liyucao_0-1716191278571.png

for example, I want to show the list of risks and count the linked experiment in a time period and show it. Actually there are 8 risks in the service I select, since 3 of 8 have no experiment so it does not show in the table.

But if I add the if condition here. The slicer does not take affect and the table shows all risks. It is very wierd.

liyucao_1-1716191388113.png

 

On the return, replace 0 to BLANK() and see what happens.





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




how to make the table contains 8 risks (of the service in the slicer) and show 0 if there is no existing experiment

Without analysing your file, I can't help you further. If you can share a sample pbix file with your example I will take a look otherwise it's a waste of time for both of us.





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




https://microsoftapc-my.sharepoint.com/:u:/g/personal/liyucao_microsoft_com/EVc0bLO3RQlAvSdTnB6rYoIB... can you view it?

As expected, the table should show all risks in serviceId A, which is 1,3,4. But the 2 method I try does not show correctly.

liyucao_0-1716199635771.png

 

Hi @liyucao,

I'm attaching a pbix file with the my solution.
The final result should be this:

_AAndrade_0-1716401135791.png

 







Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Thanks, it really helps. I am trying to understand the measure.

It will still show the 5 risks that exists in experiment table.

liyucao_0-1716197320343.png

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors