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

Sum if two colomn values are equal

Hi!

 

I'm trying to sum the cases where to two values are equal at a lower level of detail. As you can see below, I have a data set containing a category, sub-category, product, status, shipment date column. I have created a column called "Shipped" that is 1 if Status is Shipped and Date of Shipment is not empty (DAX: 

Shipped = IF(AND(RELATED('Sub-Category_Table'[Status])="Shipped", NOT(ISBLANK('Product_Table'[Date of Shipment]))), 1, 0).

If I create a Table Visualisation in PBI (2nd box below), I can sum the Shipped column and simply count the number of orders within each Sub-Category. I would like to create a measure or column (??? in the screenshot below) that is 1 when the sum of Shipped and Count of Order is equal on the sub-category level and otherwise 0. Ultimately, I want to summarize that number across categories or within a single category (I simply do it with a Card and Slicer right now).
 
I have no idea how to make the ???-measure/column. Can anyone help?

 

ThomasWW_0-1611933313646.png

 

The datamodel is relatively simply. Category is top-layer, Sub-Category middle-layer and Orders are the lowest layer. One-to-Many relationship between Category and Sub-Category, and One-to-Many between Sub-Category and Order. 

 

Thanks, 

Thomas

 

1 ACCEPTED SOLUTION
V-pazhen-msft
Community Support
Community Support

@ThomasWW 

I guess you do not need related or additional conditions. I have used your first table as sample and create the following measure:

 
Measure = IF(SUM([Shiped])=COUNT([Order]),1,0)
 

V-pazhen-msft_0-1612248943930.png

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
V-pazhen-msft
Community Support
Community Support

@ThomasWW 

I guess you do not need related or additional conditions. I have used your first table as sample and create the following measure:

 
Measure = IF(SUM([Shiped])=COUNT([Order]),1,0)
 

V-pazhen-msft_0-1612248943930.png

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

 

lbendlin
Super User
Super User

The problem is not only your ???-measure - you need separate measures, one for the subcategory and one for the category, as they have different mathematical rules.

 

first measure is count(shipped)=sum (count of order)   (crazy, eh?)

second measure actually needs an iterator. For the category you need to list all subcategories, collect their measures, and then add that up.

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.