Forum Discussion
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] |
| 3523254 | 26 |
| 3523253 | 33 |
This is the table
| Shipment | Material | Country Key | Pallet Number |
| 3523253 | 69199001 | Bulgaria | 1 |
| 3523253 | 77200895 | Bulgaria | 1 |
| 3523253 | 77201310 | Bulgaria | 1 |
| 3523253 | 77200895 | Bulgaria | 3 |
| 3523253 | 77200895 | Bulgaria | 3 |
| 3523253 | 77199968 | Bulgaria | 2 |
| 3523253 | 77200895 | Bulgaria | 5 |
| 3523253 | 77199968 | Bulgaria | 11 |
| 3523253 | 77204562 | Bulgaria | 0 |
| 3523253 | 77200895 | Bulgaria | 0 |
| 3523253 | 77199968 | Bulgaria | 0 |
| 3523253 | 77204562 | Bulgaria | 7 |
| 3523254 | 69199001 | Bulgaria | 26 |
| 3523254 | 77205189 | Bulgaria | 2 |
| 3523254 | 77201385 | Bulgaria | 2 |
| 3523254 | 77206282 | Bulgaria | 1 |
| 3523254 | 77206282 | Bulgaria | 1 |
| 3523254 | 77198412 | Bulgaria | 4 |
| 3523254 | 77201237 | Bulgaria | 1 |
| 3523254 | 77202561 | Bulgaria | 2 |
| 3523254 | 77205189 | Bulgaria | 1 |
| 3523254 | 77205189 | Bulgaria | 1 |
| 3523254 | 77205189 | Bulgaria | 1 |
| 3523254 | 77134316 | Bulgaria | 1 |
| 3523254 | 77201385 | Bulgaria | 0 |
| 3523254 | 77175551 | Bulgaria | 0 |
| 3523254 | 77202561 | Bulgaria | 0 |
| 3523254 | 77206761 | Bulgaria | 0 |
| 3523254 | 77206282 | Bulgaria | 0 |
| 3523254 | 77181972 | Bulgaria | 0 |
| 3523254 | 77198412 | Bulgaria | 0 |
| 3523254 | 77205189 | Bulgaria | 0 |
| 3523254 | 77175551 | Bulgaria | 1 |
| 3523254 | 77175551 | Bulgaria | 2 |
| 3523254 | 77206507 | Bulgaria | 1 |
| 3523254 | 77181972 | Bulgaria | 2 |
| 3523254 | 77206552 | Bulgaria | 1 |
| 3523254 | 77206761 | Bulgaria | 2 |
Thank you again !
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:
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 regardsDenisBlog: WhatTheFact.biFollow me: twitter.com/DenSelimovic
6 Replies
- PaulMcDkFrequent Visitor
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.
Shipment Material Country Key Pallet Number 352325369199001Bulgaria13523253 77200895 Bulgaria 1 3523253 77201310 Bulgaria 1 3523253 77200895 Bulgaria 3 3523253 77200895 Bulgaria 3 3523253 77199968 Bulgaria 2 3523253 77200895 Bulgaria 5 3523253 77199968 Bulgaria 11 3523253 77204562 Bulgaria 0 3523253 77200895 Bulgaria 0 3523253 77199968 Bulgaria 0 3523253 77204562 Bulgaria 7 - selimovdMost Valuable Professional
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:
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 regardsDenisBlog: WhatTheFact.biFollow me: twitter.com/DenSelimovic
- hashtag_peteHelper 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:
Cheers
hashtag_pete
- PaulMcDkFrequent Visitor
that's great ! bravo