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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

exclude some names from calculate

Hi guys,

I've got the number of wagons in one column and in another one ive got different client names. Literally just two columns. Now I need to sum wagon numbers only for two clients under title names "A" and "B". Then I need to sum wagon numbers again, but exclude those two clients. I cant figure out how to do it, when i have the names of those clients. 

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

e1.png

 

You may create two measures as below.

AB = 
CALCULATE(
    SUM('Table'[Num of wagons]),
    FILTER(
        ALL('Table'),
        [Client Name] in {"A","B"}
    )
)
Not AB = 
CALCULATE(
    SUM('Table'[Num of wagons]),
    FILTER(
        ALL('Table'),
        NOT([Client Name] in {"A","B"})
    )
)

 

Result:

e2.png

 

Best Regards

Allan

 

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-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

e1.png

 

You may create two measures as below.

AB = 
CALCULATE(
    SUM('Table'[Num of wagons]),
    FILTER(
        ALL('Table'),
        [Client Name] in {"A","B"}
    )
)
Not AB = 
CALCULATE(
    SUM('Table'[Num of wagons]),
    FILTER(
        ALL('Table'),
        NOT([Client Name] in {"A","B"})
    )
)

 

Result:

e2.png

 

Best Regards

Allan

 

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

 

Anonymous
Not applicable

First off, you should not limit the measures to only 2 clients. They should work with any number of clients which would be selected from a slicer. Based on this assumption, you could write them like so:

[Wagons for Selected Clients] =
SUM( YourTable[Wagons] )

[Wagons for All excl. Selected] =
var __allClients =
    CALCULATE(
        [Wagons for Selected Clients],
        ALL( YourTable )
    )
var __selectedClients =
    [Wagons for Selected Clients]
return
    __allClients - __selectedClients
amitchandak
Super User
Super User

@Anonymous ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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