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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Calculation Difference Between Two Numbers in Two Tables Only

I am trying to compare the price of two different products across time, but on some dates I might not have price date for both products, so I want to exclude dates.  As you can see on the bottom of the picture, I didn't have both prices on September 3, so when I calculate to subtract those two numbers, it assumes that's a zero instead of omitting it.  

 

Here is my current calculation:

 

GAP = 'Daily Price 1'[$]-related('Daily Price 2'[$])

 

 

Price Comparison.png

1 ACCEPTED SOLUTION
mwegener
Most Valuable Professional
Most Valuable Professional

Hi,

 

with a if statement you can check if both prices exists.

 

GAP = IF( ISBLANK('Daily Price 1'[$]) || ISBLANK(RELATED('Daily Price 2'[$])), BLANK(), 'Daily Price 1'[$]-RELATED('Daily Price 2'[$]) )

 

The BLANK() GAP can be filtered on the visual level

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


View solution in original post

2 REPLIES 2
mwegener
Most Valuable Professional
Most Valuable Professional

Hi,

 

with a if statement you can check if both prices exists.

 

GAP = IF( ISBLANK('Daily Price 1'[$]) || ISBLANK(RELATED('Daily Price 2'[$])), BLANK(), 'Daily Price 1'[$]-RELATED('Daily Price 2'[$]) )

 

The BLANK() GAP can be filtered on the visual level

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


MattAllington
Community Champion
Community Champion

There is a visual level filter you can set to filter out zeros etc. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.