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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Filter context

Hi all. I can not seem to figure out the filter context and calculated column will not give me the expected results.

The measure is the following:

Teams Channels =

VAR current_user = 'Teams statistics'[User Principal Name]
VAR amount_per_user= CALCULATE(SUM('Teams statistics'[Team Chat Message Count]), FILTER('Teams statistics','Teams statistics'[User Principal Name]=current_user))
return
IF(amount_per_user>=2, "Yes", "No")
 
And as per screenshot where count is 1 it says "Yes" but as per above condition it should not. Can you advise how to amend it?
Capture.JPG

 

6 REPLIES 6
AntrikshSharma
Super User
Super User

@Anonymous  Can you please attach sample dataset?

CNENFRNL
Community Champion
Community Champion

Hi, @Anonymous , with regard to this part of the measure in question, 

VAR amount_per_user =
CALCULATE (
    SUM ( 'Teams statistics'[Team Chat Message Count] ),
    FILTER (
        'Teams statistics',
        'Teams statistics'[User Principal Name] = current_user
    )
)

 'Teams statistics' is already filtered in the initial filter context (row from table/matrix, selection of slicer, interaction from other viz, etc.) before it's further filtered by FILTER().

 

I assume that you tend to filter the whole 'Teams statistics' table with condition 'Teams statistics'[User Principal Name] = current_user; if so, this variable can be simplified this way,

VAR amount_per_user =
CALCULATE (
    SUM ( 'Teams statistics'[Team Chat Message Count] ),
    'Teams statistics'[User Principal Name] = current_user
)

This classic article by Jeffrey Wang unveiled some sophisticated details of mechanism of filter context. I strongly recommend it if you'd like to dig deeper into filter context in DAX. Enjoy!


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

Thanks, @CNENFRNL 

Your example is bit closer to what I want but still not ideal.

Capture.JPG

 

 

Now one user gives me wrong result and somehow I think I need to take period into the account? The example shows where 2 is shown as "Yes" which is great and bottom one is wrong. I am also filtering the visual itself by week offset (taking only last 4 weeks) . The difference between these users is:

table.JPG

 

 

 

Anonymous
Not applicable

@CNENFRNL , also Teams Channels is calculated column I am trying to create as later I will have to count "Yes'es". Could it be the problem ?

AntrikshSharma
Super User
Super User

@Anonymous  Is 'Teams statistics'[User Principal Name] a measure or a refrence to a column or you didn't wrap inside SELECTEDVALUE?

Try this:

 

Teams Channels =
VAR current_user = 'Teams statistics'[User Principal Name]
VAR amount_per_user =
    CALCULATE (
        SUM ( 'Teams statistics'[Team Chat Message Count] ),
        'Teams statistics'[User Principal Name] = current_user,
        REMOVEFILTERS ( 'Teams statistics' )
    )
RETURN
    IF ( amount_per_user >= 2, "Yes", "No" )

 

Anonymous
Not applicable

@AntrikshSharma 

Thank you and apologies, this is not the measure but calculated column I am trying to get as eventually I will have to count "Yes'es" and not sure if masure will serve this purpose...?

 'Teams statistics'[User Principal Name]  is a column, and I di not wrap it in VALUES. 

I am afraid your suggestion still gives me same result 😞

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

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.