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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Pooja_Dasani_98
Frequent Visitor

DAX measure for division (Profit and Loss)

Budget Variance % =
 IF(
    [Financial value Var] < 0 && (ISBLANK([Financial Value2]) || [Financial Value2] = 0),
    0,
    DIVIDE([Financial value Var], [Financial Value2], 0)
)
This is the measure I have created for calculating Variance and I am trying to get the result as 0 if the numerator value is negative and it is divided by a blank value/0 the result should be 0.

The highlighted value should be 0 in this case, how can I modify my measure to reflect 0 if the result is a positive/negative undefined exponential number in percentage?

Pooja_Dasani_98_0-1722551846505.png

 

2 ACCEPTED SOLUTIONS
Shravan133
Solution Sage
Solution Sage

Hi,

Your dax measure looks okay to me. are you passing the right measures? if yes, try this workaround:

Budget Variance % =
VAR varResult =
IF(
[Financial value Var] < 0 && (ISBLANK([Financial Value2]) || [Financial Value2] = 0),
0,
DIVIDE([Financial value Var], [Financial Value2], 0)
)
RETURN
IF(
ABS(varResult) > 1E10 || ABS(varResult) < 1E-10,
0,
varResult
)

 

ABS(varResult) > 1E10 || ABS(varResult) < 1E-10: This checks if the absolute value of varResult is greater than 10^{10} (a very large number) or less than 10^{-10} (a very small number). change the exponent value accordingly.

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

This simplified measure should work

Budget Variance % = IF([Financial value Var] < 0,0,DIVIDE([Financial value Var], [Financial Value2],0))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
v-xinruzhu-msft
Community Support
Community Support

Hi,

Thanks for the solution @Ashish_Mathur  and @Shravan133  offered, and i want to offer some more information for user to refer to.

hello @Pooja_Dasani_98 , 

Please check that if your data type of the [Financial Value2] measure is Decimal number, but you don't keep one or two decimal places, then it will dispaly 0,  but in fact, there are numbers after the decimal point, in this situation , it will return the value, you can refer my sample.

vxinruzhumsft_1-1722568069534.png

 

 

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you @Ashish_Mathur , and @Shravan133  both of the solutions worked. 
@v-xinruzhu-msft , thank you for this info. 

You are welcome.

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

This simplified measure should work

Budget Variance % = IF([Financial value Var] < 0,0,DIVIDE([Financial value Var], [Financial Value2],0))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Shravan133
Solution Sage
Solution Sage

Hi,

Your dax measure looks okay to me. are you passing the right measures? if yes, try this workaround:

Budget Variance % =
VAR varResult =
IF(
[Financial value Var] < 0 && (ISBLANK([Financial Value2]) || [Financial Value2] = 0),
0,
DIVIDE([Financial value Var], [Financial Value2], 0)
)
RETURN
IF(
ABS(varResult) > 1E10 || ABS(varResult) < 1E-10,
0,
varResult
)

 

ABS(varResult) > 1E10 || ABS(varResult) < 1E-10: This checks if the absolute value of varResult is greater than 10^{10} (a very large number) or less than 10^{-10} (a very small number). change the exponent value accordingly.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

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