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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Marit
Helper II
Helper II

Subtract two columns based on conditions

Hi! 

 

I try to calculate a new column, where I want to subtract two columns from different tables if one of the columns is not blank. I used this DAX: 

DB2perareal = CALCULATE(AVERAGE(Slakteegenskaper[DB1perareal]) - AVERAGE(PriskonstantDB2[Priskonstant]), NOT(ISBLANK(Slakteegenskaper[DB1perareal])))
 
However, if Slakteegenskaper[DB1perareal] is blank, this formula gives 0 - PriskonstantDB2[Priskonstant]). 
 
Could anyone help me out with this?
 
Regards Marit
1 ACCEPTED SOLUTION
saravanan_p
Resolver III
Resolver III

So in my understanding, you dont want to substact when that column has blank right.
In that case, you rewrite as folows:

if(not(blank(col1)), col1- col2, "Pass your else command")

Pass your else command when blank value appears.

 

Hope this solves the problem and kindly mark this as solution 

View solution in original post

3 REPLIES 3
saravanan_p
Resolver III
Resolver III

So in my understanding, you dont want to substact when that column has blank right.
In that case, you rewrite as folows:

if(not(blank(col1)), col1- col2, "Pass your else command")

Pass your else command when blank value appears.

 

Hope this solves the problem and kindly mark this as solution 

@msbiuser1 Thanks

Seems to be correct. I was about to write the same logic. 

@Marit  Kindly mark as solution . 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

Top Solution Authors