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
tbennett93
Frequent Visitor

Why doesn't my filter work properly in a dimensional model but it works fine as one big table?

I have this table (the data has been mocked up for demonstration but is repeatable in PBI):

Name    Score                   Question ID

John101
Jane201
John302
Jane402
Jim502

 

If I want to show Jane's score for each question, I add the measure:

 

 

 

Jane's Score = CALCULATE(
                        SUM('Table'[Score]),
                    FILTER(
                        ALLEXCEPT(
                            'Table',
                            'Table'[Question ID]
                        ),
                    'Table'[Name] = "Jane"
                    )
)

 

 

 

 

This returns, as expected, Jane's score for each question:

tbennett93_0-1673632123681.png

 

 

Now if I transform this into a dimensional model, where my Name becomes a dimension. I have:

tbennett93_1-1673632208619.png

tbennett93_2-1673632217497.png

tbennett93_3-1673632238330.png

 

So if I want to display a table with everybody's score for each question and then a column for Jane's score too, I add the measure:

 

Janes Score v2 = CALCULATE(
sum(Merge1[Score]),
FILTER(
ALLEXCEPT(
Merge1,
Merge1[Question ID]
)
,RELATED(Names[Name])="Jane")
)

 

If I put this into a table with the Score and click 'Don't Summarize' on the score in the fields for the visual, my table turns into this:

tbennett93_4-1673632361812.png

 

Why are so many redundant rows being returned and how do I stop it?

 

It is related to 'don't summarize', but I don't know why this option causes this to happen and i'd like to understand why this is happening.

 

Thanks

 

 

1 REPLY 1
lbendlin
Super User
Super User

You are applying the filter to the "wrong"  table (the fact table).  You are supposed to filter by dimension columns.

 

Look at the arrow in your data model.  The filter on the fact cannot travel back up to the dimension.

 

ALLEXCEPT is a very blunt instrument. It messes with your filter context - remove ALL filters EXCEPT that one.  Try to use it sparingly,  Use RemoveFilters, or AllSelected etc.

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.

Top Solution Authors