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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Spotlamp
Frequent Visitor

Page filters ignored when using a calculate and a zero to replace blanks

Hello,

 

I've got two data tables, a parent table left joined to a child table.  On the parent table I've applied a filter to show only four records.  One of those filtered parent records has a child, the other three parent records do not.  I've written the following measure to count the number of children for each of the four parent records:

ChildCount =
CALCULATE(
COUNTA('Child'[Child_id]),
ALLSELECTED('Parent'[Parent_ID])
)

When I add the calculated column to a table visual it filters out the three parent records that have zero child records.  So then I tried the following:

ChildCount =
CALCULATE(
COUNTA('Child'[Child_id]),
ALLSELECTED('Parent'[Parent_ID])
) + 0

The problem is that this now returns every parent record and ignores the filer that I have to only show four parent records.

 

Any idea what's gone wrong?  I'm sure it's an easy fix somewhere and most likely to do with the way I'm trying to show zeros in my measure when there are no child records.

 

Many thanks

H

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

Hi @Spotlamp ,

Please check the thread below which is similar to your problem, you can get the answer from it.

ALLSELECTED not being applied for calculated columns

In addition, if you want to understand the cause of this problem well, you may need to understand the difference and application scenarios between the calculated column and the measure. You can review these two blogs below for details.

Measure vs Calculated Column: The Mysterious Question? Not!

Calculated Columns and Measures in DAX

Best Regards

Community Support Team _ Rena
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

1 REPLY 1
v-yiruan-msft
Community Support
Community Support

Hi @Spotlamp ,

Please check the thread below which is similar to your problem, you can get the answer from it.

ALLSELECTED not being applied for calculated columns

In addition, if you want to understand the cause of this problem well, you may need to understand the difference and application scenarios between the calculated column and the measure. You can review these two blogs below for details.

Measure vs Calculated Column: The Mysterious Question? Not!

Calculated Columns and Measures in DAX

Best Regards

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.