cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

Frequent Visitor

## Multiple aggregation Distinct Count (3 Filters)

Hello Everyone,

I´m trying to get to count (distinct) how many times a Pallet Code was used multiple times for different deliveries within the same shipment Number --> A shipment can contain multiple Deliveries and the deliveries can have the same pallet code

 Shipment Number Delivery Number Pallet Code DISTINCTCOUNT Expected Output 234 8 555 3 234 6 555 3 234 5 555 3

The example above contains one Shipment Number (555) with multiple deverlies where they all used the same Pallet Code, menaing the pallet code has been used 3 times within the same Shipment and multiple deliveries

I used this, but seems not working well:

``Countv1 = COUNTROWS(FILTER(SSCC, SSCC[Shipment Number] = EARLIER(SSCC[Shipment Number]) && SSCC[Pallet Code] = EARLIER(SSCC[Pallet Code])))``

Many thanks!

1 ACCEPTED SOLUTION
Super User

@manuelfigueirat , if this is a column, this seems fine

countx(filter( SSCC, SSCC[Shipment Number] = EARLIER(SSCC[Shipment Number]) && SSCC[Pallet Code] = EARLIER(SSCC[Pallet Code])),[Shipment Number])

for measure

countx(filter(allselected( SSCC), SSCC[Shipment Number] = MAX(SSCC[Shipment Number]) && SSCC[Pallet Code] = MAX(SSCC[Pallet Code])),[Shipment Number])

Super User

@manuelfigueirat , if this is a column, this seems fine

countx(filter( SSCC, SSCC[Shipment Number] = EARLIER(SSCC[Shipment Number]) && SSCC[Pallet Code] = EARLIER(SSCC[Pallet Code])),[Shipment Number])

for measure

countx(filter(allselected( SSCC), SSCC[Shipment Number] = MAX(SSCC[Shipment Number]) && SSCC[Pallet Code] = MAX(SSCC[Pallet Code])),[Shipment Number])

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

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

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors