cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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

Hi @liyucao,

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

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

Proud to be a Super User!

11 REPLIES 11
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!

Employee

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

Super User

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!

Employee

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.

Super User

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!

Employee

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

Super User

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!

Employee

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.

Super User

Hi @liyucao,

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

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

Proud to be a Super User!

Employee

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

Employee

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

Announcements

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors