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
PaulMcDk
Frequent Visitor

SUM + DISTINCTCOUNT support

Dear community,

 

first, thanks for great support you are providing.

I have this table with #2 different Shipment (first column).

 

I would like to have a measure - called "pallet number" that does, for each Shipment, the column R (Cty) by filtering : NOT Material (691*) and Country Key ("Bulgaria").

So for example the expected result should :

 

Shipment

[Pallet Number]

352325426
352325333

 

This is the table

 

ShipmentMaterialCountry KeyPallet Number
352325369199001Bulgaria1
352325377200895Bulgaria1
352325377201310Bulgaria1
352325377200895Bulgaria3
352325377200895Bulgaria3
352325377199968Bulgaria2
352325377200895Bulgaria5
352325377199968Bulgaria11
352325377204562Bulgaria0
352325377200895Bulgaria0
352325377199968Bulgaria0
352325377204562Bulgaria7
352325469199001Bulgaria26
352325477205189Bulgaria2
352325477201385Bulgaria2
352325477206282Bulgaria1
352325477206282Bulgaria1
352325477198412Bulgaria4
352325477201237Bulgaria1
352325477202561Bulgaria2
352325477205189Bulgaria1
352325477205189Bulgaria1
352325477205189Bulgaria1
352325477134316Bulgaria1
352325477201385Bulgaria0
352325477175551Bulgaria0
352325477202561Bulgaria0
352325477206761Bulgaria0
352325477206282Bulgaria0
352325477181972Bulgaria0
352325477198412Bulgaria0
352325477205189Bulgaria0
352325477175551Bulgaria1
352325477175551Bulgaria2
352325477206507Bulgaria1
352325477181972Bulgaria2
352325477206552Bulgaria1
352325477206761Bulgaria2

 

Thank you again !

1 ACCEPTED SOLUTION

Hey @PaulMcDk ,

 

thank you for the explanation, now it makes sense 😊

The following measure should give you the result you want:

Pallet Number NEW =
CALCULATE(
    SUM( 'Table'[Pallet Number] ),
    LEFT( 'Table'[Material], 3 ) <> "691" && 'Table'[Country Key] = "Bulgaria"
)

 

And that's the result:

selimovd_0-1627297551515.png

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

 

 

View solution in original post

6 REPLIES 6
PaulMcDk
Frequent Visitor

that's great ! bravo

hashtag_pete
Helper V
Helper V

Hello Paul, 

try this:

 

Distinct Count = SUMX( CALCULATETABLE( Tabelle1, Tabelle1[Country Key] = "Bulgaria", LEFT(Tabelle1[Material],3) <> "691"), Tabelle1[Pallet Number] )

 

This worked for me in a table visualisation:

hashtag_pete_0-1627298342577.png

Cheers

hashtag_pete

selimovd
Super User
Super User

Hey @PaulMcDk ,

 

I understood the requirements, but how do you end up with the result 26? What should 26 be?

Can you explain the result a little better?

 

Thank you and best regards

Denis

Ciao @selimovd ,

 

33 is the sum of each line for the shipment 3523253 excluding the first line with material "69199001"

So basically the sum of column Pallet Number.

 

ShipmentMaterialCountry KeyPallet Number
352325369199001Bulgaria1
352325377200895Bulgaria1
352325377201310Bulgaria1
352325377200895Bulgaria3
352325377200895Bulgaria3
352325377199968Bulgaria2
352325377200895Bulgaria5
352325377199968Bulgaria11
352325377204562Bulgaria0
352325377200895Bulgaria0
352325377199968Bulgaria0
352325377204562Bulgaria7
    

 

Hey @PaulMcDk ,

 

thank you for the explanation, now it makes sense 😊

The following measure should give you the result you want:

Pallet Number NEW =
CALCULATE(
    SUM( 'Table'[Pallet Number] ),
    LEFT( 'Table'[Material], 3 ) <> "691" && 'Table'[Country Key] = "Bulgaria"
)

 

And that's the result:

selimovd_0-1627297551515.png

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

 

 

Dear Selimovd,

 

how are you doing ?

I'm using the solution you suggested but i notice it has a limit (not depending on you).

Formula is fine if i want to count #pallet per shipment BUT if i add another dimension it is not working .

 

For istance:

Table A - Shipment 
ShipmentMaterialBRAND
123456771….1TUNA 
123456771….2TUNA 
123456771….3SALMON
123456771….4SALMON
   
234567771….1TUNA 
234567771….2TUNA 
234567771….3SALMON
234567771….4SALMON
   
345678771….1TUNA 
345678771….2TUNA 
345678771….3SALMON
345678771….4SALMON
   
Table B - Pallet  
ShipmentMaterialPallet
123456771….13
123456771….25
123456771….318
123456771….47
   
234567771….15
234567771….29
234567771….311
234567771….414
   
345678771….132
345678771….21
345678771….32
345678771….45

 

the two tables are linked with a relation Many:Many via "Shipment" key . 

Now, if i want to have a new table with:

 

BRAND       PALLET #

TUNA

SALMON

 

The formula is counting the total number of shipment without considering the BRAND.

So the total (or subtotal) per BRAND is wrong .

 

Any idea ?

 

thank you !

 

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.