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
Anonymous
Not applicable

Need help with DAX DIVIDE

Hi can someone pls tell me whats wrong with the below formula -

 

= if(SUM('Install Count Devices'[Installed Device Quantity]) = 0, blank(),DIVIDE([Failure Count],[Installed Device Quantity],0))

 

 

When I added this in SSAS Tabular model as a calculated column, I get error as below 

 

"Installed Device Quantity is not found or cannot be used in this expression". And the error is with the second instance of [Installed Device Quantity] in the formula. Can someone tell me whats wrong with the Divide function or what else.

 

Thanks

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks All for the inputs. I got it resolved by making installed device quantity as a meausre instead of calculated oclumn.

View solution in original post

9 REPLIES 9
Anonymous
Not applicable

Thanks All for the inputs. I got it resolved by making installed device quantity as a meausre instead of calculated oclumn.

Hi @Anonymous,

 

Thanks for your sharing. Please kindly mark your shared solution as an answer so that others having similar problem can find the solution more easily.

 

Regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
pawel1
Kudo Kingpin
Kudo Kingpin

agree with diblet17.  no need of the last 0

Measure = if(SUM('Install Count Devices'[Installed Device Quantity]) = 0, blank(),DIVIDE([Failure Count],[Installed Device Quantity],0))

Anonymous
Not applicable

@mattbrice@Anonymous@Anonymous I guess the problem is with the divide function having numerator from one table and denominator from another table. Is that a valid case to divide one field by another field from two different tables in SSAS.

Anonymous
Not applicable

@AnonymousYou could test this theory by declaring a variable and putting the 'other table' value into the variable.  Then use the variable in your divide.

mattbrice
Solution Sage
Solution Sage

Is the column in the table :  'Install Count Devices' ?  The first time you used it you fully qualified the column name, second time you did not.  Try fully qualifying it:  'Install Count Devices'[Installed Device Quantity].  

 

This is a best practice anyway for code readability. Columns include table name, measures do not.

 

Also if this is a calculated column, the expression "SUM('Install Count Devices'[Installed Device Quantity])"  will SUM all the values in the entire 'Installed Device Quantity' column in the 'Install Count Devices' table as you have no context transition happening.  CALCULATE needed for that.

Anonymous
Not applicable

Hi,

 

It's my understanding that the divide function handles dividing by zero on it's own so there's no need for the IF(SUM() = 0, BLANK(), DIVIDE()) statement, that could simply be written as:

Divide(Col1, Col2, BLANK())

with the third argument being the output when you divide by zero, which is what the IF() statement was doing.

 

I don't think this helps with your error however, it seems unrelated. Try simplifying the code as suggest and perhaps it will become more clear?

 

Thanks,

Will

Anonymous
Not applicable

Without knowing your full data structure, is the table in which you are creating this custom column the same table that has the column [Failure Count] and [Installed Device Quantity]?

 

The way you have referenced them assumes that are on the same data row as the created column as it runs.  Is this actually the case in your tables?

Anonymous
Not applicable

@Anonymous The column [Failure Count] is in the same table where I am adding the calculated column. But the column [Installed Device Quantity] is in a different table (table name - Install count devices) and it is a calculated column in that table.  The formula 

 

Failure % = if('Install Count Devices'[Installed Device Quantity] = 0, blank(),[Failure Count]/[Installed Device Quantity]) worked in Power BI but not working in SSAS. And there is no relationship between the two tables. 

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.