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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
New_be
Helper V
Helper V

My filter does not working

Hi expert,
I have a simple question (shoulod be simple, but I cannot get the answer).

I have 3 tables. 2 dimensions (Calendar & area) and 1 fact table.
Relation.jpg

From matrix table, I wanted to created a visual like below with reporter at row, and YearWeek as column and YES if there is a title registered in DAB table. But with my current measure, when I filter on the plant, for example MY, it will show all reporters. It should only return reporter under plant MY. But now it shows all. Below is my measure;

YesOrNo Gemba TEST =
VAR RegistrationCount =
    CALCULATE(
        COUNT('DAB Action List'[Title])
    )
RETURN
    IF(RegistrationCount > 0, "YES", "NO")



What I got.jpg

 

Visual that I desired. If I click on MY, it will show only MY registration. If JAP, it will show JAP only.

What I desired.jpg

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @New_be

 

From what I understand from your post, I believe the sources of this unwanted behaviour are that:

1. When RegistrationCount is BLANK, the expression

 

IF ( RegistrationCount > 0, "YES", "NO" )

 

returns "NO" (since, in DAX, BLANK = 0 for the purpose of comparisons).

 

2. When Power BI generates the DAX query for the matrix visual, the three columns Reporter, YearWeek and Plant (which "filter" a given cell of the matrix) are all from different tables, so non-existing combinations are not automatically excluded by auto-exist.

 

Putting these together, the problem arises because:

  • Combinations of Reporter/YearWeek/Plant that don't exist in 'DAB Action List' (expanded table) will still appear in the query generated by the visual.
  • RegistrationCount will be blank for those particular rows, but the measure convertes this to a nonblank values "NO".
  • So the visual will contain values for Reporter that do not relate to the filtered Plant.

Generally, converting blank values (resulting from aggregation of a table) to nonblank values goes against the optimizations of the DAX engine and can produce unexpected results, in this case returning results for combinations that don't make sense.

 

Possible solutions:

1. If you are happy to return BLANK rather than "NO", then change the measure to:

 

YesOrNo Gemba TEST =
VAR RegistrationCount =
    COUNT ( 'DAB Action List'[Title] )
RETURN
    IF (
        RegistrationCount > 0, -- or NOT ISBLANK ( RegistrationCount )
        "YES"
    )

 

Note that this would eliminate any columns or rows from the matrix where only blank values are returned (unless you enable "Show items with no data" on the Row/Column fields).

 

2. If you still want to "fill in the blanks" and return "NO" for cells where RegistrationCount is BLANK, but only for Reporters that exist in 'DAB Action List' subject to the other filters, you could write a measure like this:

 

YesOrNo Gemba TEST =
VAR RegistrationCount = COUNT ( 'DAB Action List'[Title] )

-- Determine whether rows exist in 'DAB Action List'
-- within the "overall" Date filter context
VAR ReporterExists =
    CALCULATE (
        NOT ISEMPTY ( 'DAB Action List' ),
        ALLSELECTED ( 'Calendar' ) -- Table containing Column field
    )
RETURN
    IF (
        ReporterExists,
        IF ( RegistrationCount > 0, "YES", "NO" )
    )

 

 

This measure only returns a nonblank result if rows exist in 'DAB Action List' for the current row of the matrix visual. You could modify the logic in ReporterExists as needed to handle different conditions.

 

See this article for some more ideas on this general topic (returning "NO" is equivalent to returning zero in this article):

https://www.sqlbi.com/articles/how-to-return-0-instead-of-blank-in-dax

 

Hoping some of this helps. Please post back if needed (a link to a sample PBIX may help) 🙂

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

1 REPLY 1
OwenAuger
Super User
Super User

Hi @New_be

 

From what I understand from your post, I believe the sources of this unwanted behaviour are that:

1. When RegistrationCount is BLANK, the expression

 

IF ( RegistrationCount > 0, "YES", "NO" )

 

returns "NO" (since, in DAX, BLANK = 0 for the purpose of comparisons).

 

2. When Power BI generates the DAX query for the matrix visual, the three columns Reporter, YearWeek and Plant (which "filter" a given cell of the matrix) are all from different tables, so non-existing combinations are not automatically excluded by auto-exist.

 

Putting these together, the problem arises because:

  • Combinations of Reporter/YearWeek/Plant that don't exist in 'DAB Action List' (expanded table) will still appear in the query generated by the visual.
  • RegistrationCount will be blank for those particular rows, but the measure convertes this to a nonblank values "NO".
  • So the visual will contain values for Reporter that do not relate to the filtered Plant.

Generally, converting blank values (resulting from aggregation of a table) to nonblank values goes against the optimizations of the DAX engine and can produce unexpected results, in this case returning results for combinations that don't make sense.

 

Possible solutions:

1. If you are happy to return BLANK rather than "NO", then change the measure to:

 

YesOrNo Gemba TEST =
VAR RegistrationCount =
    COUNT ( 'DAB Action List'[Title] )
RETURN
    IF (
        RegistrationCount > 0, -- or NOT ISBLANK ( RegistrationCount )
        "YES"
    )

 

Note that this would eliminate any columns or rows from the matrix where only blank values are returned (unless you enable "Show items with no data" on the Row/Column fields).

 

2. If you still want to "fill in the blanks" and return "NO" for cells where RegistrationCount is BLANK, but only for Reporters that exist in 'DAB Action List' subject to the other filters, you could write a measure like this:

 

YesOrNo Gemba TEST =
VAR RegistrationCount = COUNT ( 'DAB Action List'[Title] )

-- Determine whether rows exist in 'DAB Action List'
-- within the "overall" Date filter context
VAR ReporterExists =
    CALCULATE (
        NOT ISEMPTY ( 'DAB Action List' ),
        ALLSELECTED ( 'Calendar' ) -- Table containing Column field
    )
RETURN
    IF (
        ReporterExists,
        IF ( RegistrationCount > 0, "YES", "NO" )
    )

 

 

This measure only returns a nonblank result if rows exist in 'DAB Action List' for the current row of the matrix visual. You could modify the logic in ReporterExists as needed to handle different conditions.

 

See this article for some more ideas on this general topic (returning "NO" is equivalent to returning zero in this article):

https://www.sqlbi.com/articles/how-to-return-0-instead-of-blank-in-dax

 

Hoping some of this helps. Please post back if needed (a link to a sample PBIX may help) 🙂

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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