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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.