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
Anonymous
Not applicable

VAR with a CountRows and adding a filter out for another column

Hello, I have the following code and am looking to add a filter to it to remove inputs in another column.  I've filtered for, but never against and never from a different column, so I'm a little out of my element. Any help would be greatly appreciated.

 

Active = VAR __CurrentRowID = Main[Employee ID]
RETURN
COUNTROWS(
FILTER(
ALL(Main),
__CurrentRowID = Main[mgr_emplid]
)
)
 
The column name is: Main[Position].  I have over 400 values in it, but would like to filter out the following values so that the column returns a count of everything else. 
 
Remove:
Team Member
Team Member - Nights
Team Member - Nights - DO
 
1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @Anonymous ,

 

As the official document said, ALL() function returns all the rows in a table, or all the values in a column, ignoring any filters that might have been applied. This function is useful for clearing filters and creating calculations on all the rows in a table.

 

Please try the following formula to add a column:

Active =
VAR __CurrentRowID = Main[Employee ID]
RETURN
    CALCULATE (
        COUNTROWS ( 'Main' ),
        FILTER (
            'Main',
            'Main'[mgr_emplid] = __CurrentRowID
                && NOT ( [Position]
                IN { "Team Member", "Team Member - Nights", "Team Member - Nights - DO" } )
        )
    )

The final output is shown below:

2.4.4.1.PNG

 

Here is the pbix file.


Best Regards,
Eyelyn Qin
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

3 REPLIES 3
v-eqin-msft
Community Support
Community Support

Hi @Anonymous ,

 

As the official document said, ALL() function returns all the rows in a table, or all the values in a column, ignoring any filters that might have been applied. This function is useful for clearing filters and creating calculations on all the rows in a table.

 

Please try the following formula to add a column:

Active =
VAR __CurrentRowID = Main[Employee ID]
RETURN
    CALCULATE (
        COUNTROWS ( 'Main' ),
        FILTER (
            'Main',
            'Main'[mgr_emplid] = __CurrentRowID
                && NOT ( [Position]
                IN { "Team Member", "Team Member - Nights", "Team Member - Nights - DO" } )
        )
    )

The final output is shown below:

2.4.4.1.PNG

 

Here is the pbix file.


Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

Anonymous
Not applicable

I read your article, and maybe I'm misunderstanding or I wasn't clear.  I'm trying to add a filter to the command to filter out certain values. 

 

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.