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
gsed99
Helper III
Helper III

Calculated field with filter excluding specificrecords

Hello,

I am trying to modify a calculated field and add a filter that will exclude certain opportunity numbers from the summation.

The formula works without the last filter, but I need to exclude certain records from the reporting.

Any help would be grealy appreciated!
Thanks,
Greg

 

 

CY # SQO (All) =
CALCULATE (
COUNT ( 'Marketing Snapshot'[SQODate] ),
FILTER (
ALL ( 'Marketing Snapshot'[SQOYear] ),
'Marketing Snapshot'[SQOYear] = [Max SQO Year]
),
FILTER (
ALL ( 'Marketing Snapshot'[DateStampMonth] ),
'Marketing Snapshot'[DateStampMonth] = [Max DateStampMonth]
),
FILTER (
ALL ( 'Marketing Snapshot'[OpportunityNumber] ),
'Marketing Snapshot'[OpportunityNumber] NOT IN {"O751700","O761393"})

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @gsed99

 

The negation of

<X> IN <Y>

is

NOT <X> IN <Y>

 

Also, since your 3rd filter argument within CALCULATE doesn't reference any measures etc, you can get rid of FILTER (ALL(...)) and get the same result.

 

This expression should work:

CY # SQO (All) =
CALCULATE (
    COUNT ( 'Marketing Snapshot'[SQODate] ),
    FILTER (
        ALL ( 'Marketing Snapshot'[SQOYear] ),
        'Marketing Snapshot'[SQOYear] = [Max SQO Year]
    ),
    FILTER (
        ALL ( 'Marketing Snapshot'[DateStampMonth] ),
        'Marketing Snapshot'[DateStampMonth] = [Max DateStampMonth]
    ),
    NOT 'Marketing Snapshot'[OpportunityNumber] IN { "O751700", "O761393" }
)

Regards,

Owen


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

View solution in original post

4 REPLIES 4
OwenAuger
Super User
Super User

Hi @gsed99

 

The negation of

<X> IN <Y>

is

NOT <X> IN <Y>

 

Also, since your 3rd filter argument within CALCULATE doesn't reference any measures etc, you can get rid of FILTER (ALL(...)) and get the same result.

 

This expression should work:

CY # SQO (All) =
CALCULATE (
    COUNT ( 'Marketing Snapshot'[SQODate] ),
    FILTER (
        ALL ( 'Marketing Snapshot'[SQOYear] ),
        'Marketing Snapshot'[SQOYear] = [Max SQO Year]
    ),
    FILTER (
        ALL ( 'Marketing Snapshot'[DateStampMonth] ),
        'Marketing Snapshot'[DateStampMonth] = [Max DateStampMonth]
    ),
    NOT 'Marketing Snapshot'[OpportunityNumber] IN { "O751700", "O761393" }
)

Regards,

Owen


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

Thanks @OwenAuger, that worked!!!

indhu
Helper III
Helper III

hey @gsed99,

 

can't this be set in visual, page or report level filters? had a thought seeing your post but not sure if that will work for you. 

 

 

hey @indhu,

I would actually need this to be done in the formula becuase my report is showing other metrics, so if I filter it on the visual, it will be limited those other metrics.

Thanks,

Greg

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.