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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
Jaypearce
Frequent Visitor

Power Bi Fomula - Exclude rows if other column is filtered

Hi all,

 

Hi all,

I have am wondering if anyone can help me with this semi odd formula.

 

Basically I want to have a filter for when "cost center" is filtered for multiple items (e.g. "CC2" & CC8"), If the filtered values appears on any rows in "Partner cost center" then that row would be excluded. I have given some large summary data and power bi file. But I cannot work out what I am doing wrong.

https://drive.google.com/drive/folders/1ze0vl4z6aCvf_Z2snzUamM9A7a30qp9N?usp=drive_link


Thanks

2 ACCEPTED SOLUTIONS
danextian
Super User
Super User

Hi @Jaypearce 

Create a disconnected table of cost centre and use a measure to visual filter your table.

Cost Centre = 
VALUES('Input Data'[Cost Center]) --Calc Table
Exclude Filter = 
VAR _count =
    COUNTROWS ( 'Cost Centre' )  // count how many cost centres are selected
VAR _isfiltered =
    ISFILTERED ( 'Cost Centre'[Cost Center] )  // check if slicer is filtered at all
VAR _result =
    SWITCH (
        TRUE (),

        // if only one selected or nothing selected, return full count (no exclusion)
        _count = 1 || NOT _isfiltered,
        COUNTROWS ( 'Input Data' ),

        // if multiple are selected, exclude them from the input data
        _isfiltered && _count > 1,
        COUNTROWS (
            EXCEPT (
                VALUES ( 'Input Data'[Partner Cost Center] ),   // all partner cost centres
                VALUES ( 'Cost Centre'[Cost Center] )           // exclude selected cost centres
            )
        )
    )
RETURN
    _result

danextian_0-1751874087391.gif

 

Please see the attached pbix. 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1752285677583.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

7 REPLIES 7
v-priyankata
Community Support
Community Support

Hi @Jaypearce 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.

Hi @Jaypearce 

Hope everything’s going smoothly on your end. We haven’t heard back from you, so I wanted to check if the issue got sorted  If yes, marking the relevant solution would be awesome for others who might run into the same thing.

Ashish_Mathur
Super User
Super User

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1752285677583.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-priyankata
Community Support
Community Support

Hi @Jaypearce 

Thank you for reaching out to the Microsoft Fabric Forum Community.

@SundarRaj @danextian Thanks for the inputs.
In addition to their input, please try below DAX & drag the Exclude Filter measure into the visual's Filters pane and set it to show only rows where the value is 1. let me know if you are still experiencing the issue.

Exclude Filter =
VAR SelectedCCs = VALUES(Summary[Cost Center])
VAR CurrentCC = SELECTEDVALUE(Summary[Cost Center])
VAR PartnerCC = SELECTEDVALUE(Summary[Partner Cost Center])
RETURN
    IF (
        NOT ISBLANK(CurrentCC) &&
        NOT ISBLANK(PartnerCC) &&
        CurrentCC IN SelectedCCs &&
        NOT PartnerCC IN SelectedCCs,
        1,
        0
    )



Thanks

Hi @Jaypearce 

I hope the information provided was helpful. If you still have questions, please don't hesitate to reach out to the community.

danextian
Super User
Super User

Hi @Jaypearce 

Create a disconnected table of cost centre and use a measure to visual filter your table.

Cost Centre = 
VALUES('Input Data'[Cost Center]) --Calc Table
Exclude Filter = 
VAR _count =
    COUNTROWS ( 'Cost Centre' )  // count how many cost centres are selected
VAR _isfiltered =
    ISFILTERED ( 'Cost Centre'[Cost Center] )  // check if slicer is filtered at all
VAR _result =
    SWITCH (
        TRUE (),

        // if only one selected or nothing selected, return full count (no exclusion)
        _count = 1 || NOT _isfiltered,
        COUNTROWS ( 'Input Data' ),

        // if multiple are selected, exclude them from the input data
        _isfiltered && _count > 1,
        COUNTROWS (
            EXCEPT (
                VALUES ( 'Input Data'[Partner Cost Center] ),   // all partner cost centres
                VALUES ( 'Cost Centre'[Cost Center] )           // exclude selected cost centres
            )
        )
    )
RETURN
    _result

danextian_0-1751874087391.gif

 

Please see the attached pbix. 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
SundarRaj
Super User
Super User

Hi @Jaypearce ,

Still working on the DAX solution of it. But did figure out a way to do what you desire on Power Query. I'll attach the sample file which has the output. Do let me know if this is what you wanted. Thanks!

https://docs.google.com/spreadsheets/d/1SquOy_Bpyyml1rcpwygMmAOtlWU3I1kz/edit?usp=sharing&ouid=10475...

SundarRaj_0-1751869723314.png

Picture above is the filter that you were talking about and how to navigate the selection. Thanks

Sundar Rajagopalan

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.