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
Cullen
New Member

Calculate difference if the cell is not blank to include multiple filters

I want to calculate the delta between Order quantity (GMEIN) and Delivered quantity (GMEIN).  If it is blank, then do not perform a calculation.  When I choose the Production Line in the slicer, I only want to see the difference between planned and delivered.  The measure I wrote will calculate the the entire difference for the production  line; I only want the difference between Order Quantiy and Delivered Quantity if there is a number in each row.

Capture.PNG

1 ACCEPTED SOLUTION
NarenM
New Member

Hi Cullen,

Approach 1 - Filtering and Calculating Delta:
This approach filters out rows with zero "Delivered Qty." and calculates the difference between "Plan Order Qty." and "Delivered Qty." for the remaining rows. It's best suited for scenarios where you only want to focus on rows with partial or full deliveries.

Filter Rows Where Delivered Qty. Is Greater Than 0:
Click on the "Delivered Qty." column.
Go to the "Home" tab, then click "Number Filters" > "Greater Than."
Enter 0, then click "OK."
Calculate the Delta Between Plan Order Qty. and Delivered Qty.:
Go to the "Add Column" tab, then click "Custom Column."
In the "New Column" window:
New column name: Enter a name for the new column (e.g., "Delta")
Formula: Enter =[Plan Order Qty.] - [Delivered Qty.]
Click "OK."

Approach 2 - Conditional Calculation Without Filtering:
This approach calculates the delta between "Plan Order Qty." and "Delivered Qty." only for rows with non-zero deliveries, without removing any rows. It uses a conditional column to leave the delta blank or zero for rows with zero "Delivered Qty." This method keeps all original data and adds the calculated delta as a new column.

Add a Conditional Column to Calculate the Delta:
Go to the "Add Column" tab, then click "Conditional Column."
In the "Add Conditional Column" window:
New column name: Enter a name for the new column (e.g., "Delta")
In the "if" section:
Column: Select "Delivered Qty."
Operator: Select "is greater than"
Value: Enter 0
Output: Enter the formula =[Plan Order Qty.] - [Delivered Qty.]
In the "Else" section, you can either leave it blank or enter 0.
Click "OK."

View solution in original post

2 REPLIES 2
Waqas_BIspecs
Frequent Visitor

Hi, 

 

Please make sure you create a calculated column for this not measure. 
i have placed a sample output table where i have calculated the difference. 

 

Waqas_BIspecs_0-1692297596286.png

 

Below is the forluma for Calculated column:

Deltacalc = if([pieces_ordered] - [pieces_shipped] = 0, 0,  [pieces_ordered] - [pieces_shipped])
If this solution works for you, please leave a Kudo. i will appriciate that.
NarenM
New Member

Hi Cullen,

Approach 1 - Filtering and Calculating Delta:
This approach filters out rows with zero "Delivered Qty." and calculates the difference between "Plan Order Qty." and "Delivered Qty." for the remaining rows. It's best suited for scenarios where you only want to focus on rows with partial or full deliveries.

Filter Rows Where Delivered Qty. Is Greater Than 0:
Click on the "Delivered Qty." column.
Go to the "Home" tab, then click "Number Filters" > "Greater Than."
Enter 0, then click "OK."
Calculate the Delta Between Plan Order Qty. and Delivered Qty.:
Go to the "Add Column" tab, then click "Custom Column."
In the "New Column" window:
New column name: Enter a name for the new column (e.g., "Delta")
Formula: Enter =[Plan Order Qty.] - [Delivered Qty.]
Click "OK."

Approach 2 - Conditional Calculation Without Filtering:
This approach calculates the delta between "Plan Order Qty." and "Delivered Qty." only for rows with non-zero deliveries, without removing any rows. It uses a conditional column to leave the delta blank or zero for rows with zero "Delivered Qty." This method keeps all original data and adds the calculated delta as a new column.

Add a Conditional Column to Calculate the Delta:
Go to the "Add Column" tab, then click "Conditional Column."
In the "Add Conditional Column" window:
New column name: Enter a name for the new column (e.g., "Delta")
In the "if" section:
Column: Select "Delivered Qty."
Operator: Select "is greater than"
Value: Enter 0
Output: Enter the formula =[Plan Order Qty.] - [Delivered Qty.]
In the "Else" section, you can either leave it blank or enter 0.
Click "OK."

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.

Top Solution Authors
Top Kudoed Authors