Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Solution Authors