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
Sarah--Flex
Frequent Visitor

zero value to be calculated

Hi all,

 

I've been using Power Bi for a few months and so far i love it... but i have an issue on a calculation and i cant figure it out.  i hope someone has the answer.

 

I have values in Zero, and I am using a IF calculation to transform 0 into 5, but so far is not working, and leaves the result as blank. I have tried 2 ways

 

Points MCARs = IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=BLANK()),BLANK(),IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]>6),0,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=5),1,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=4),2,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=3),3,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=2),4,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=1),5,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=0),5,0))))))))

 

and this

 

Points MCARs = IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=BLANK()),BLANK(),IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]>6),0,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=5),1,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=4),2,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=3),3,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=2),4,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]<=1),5,0)))))))

 

it calculates all of the conditional except the zero.   (see the last IF calculation in the formula)

 

what am i doing wrong?

 

thanks for your help

 

Sarah

1 ACCEPTED SOLUTION
davehus
Memorable Member
Memorable Member

Hi, I've change the code slightly and it should work now. Where you are declaring the blank, try to wrap it with an ISBLANK formula as below.

 

HTH 

 

D

 

Please mark as a solution if you are happy with the result.

 

 

=
IF (
AND ( 'Raw Data'[Metric] = "MCARs", ISBLANK('Raw Data'[Score])),
BLANK (),
IF (
AND ( 'Raw Data'[Metric] = "MCARs", 'Raw Data'[Score] > 6 ),
0,
IF (
AND ( 'Raw Data'[Metric] = "MCARs", 'Raw Data'[Score] = 5 ),
1,
IF (
AND ( 'Raw Data'[Metric] = "MCARs", 'Raw Data'[Score] = 4 ),
2,
IF (
AND ( 'Raw Data'[Metric] = "MCARs", 'Raw Data'[Score] = 3 ),
3,
IF (
AND ( 'Raw Data'[Metric] = "MCARs", 'Raw Data'[Score] = 2 ),
4,
IF ( AND ( 'Raw Data'[Metric] = "MCARs", 'Raw Data'[Score] <= 1 ), 5, 0 )
) )))))

 

View solution in original post

4 REPLIES 4
Sarah--Flex
Frequent Visitor

hello all,

 

I'm very new in Power Bi... so far i love it.   but i need your help with.   My data base has values as zero, and i need it to be taken into consideration as a value so when I run my IF calculation gives me a result of 5 points.  so far the value ZERO is not translated into the 5 that i need.   it keeps the result as blank

 

so far i have tried this:

Points MCARs = IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=BLANK()),BLANK(),IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]>6),0,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=5),1,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=4),2,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=3),3,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=2),4,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]<=1),5,0)))))))

 

and this

Points MCARs = IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=BLANK()),BLANK(),IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]>6),0,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=5),1,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=4),2,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=3),3,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=2),4,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=1),5,IF(AND('Raw Data'[Metric]="MCARs",'Raw Data'[Score]=0),5,0))))))))

 

 

hope you can help.   thanks

 

 

 

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
davehus
Memorable Member
Memorable Member

Hi, I've change the code slightly and it should work now. Where you are declaring the blank, try to wrap it with an ISBLANK formula as below.

 

HTH 

 

D

 

Please mark as a solution if you are happy with the result.

 

 

=
IF (
AND ( 'Raw Data'[Metric] = "MCARs", ISBLANK('Raw Data'[Score])),
BLANK (),
IF (
AND ( 'Raw Data'[Metric] = "MCARs", 'Raw Data'[Score] > 6 ),
0,
IF (
AND ( 'Raw Data'[Metric] = "MCARs", 'Raw Data'[Score] = 5 ),
1,
IF (
AND ( 'Raw Data'[Metric] = "MCARs", 'Raw Data'[Score] = 4 ),
2,
IF (
AND ( 'Raw Data'[Metric] = "MCARs", 'Raw Data'[Score] = 3 ),
3,
IF (
AND ( 'Raw Data'[Metric] = "MCARs", 'Raw Data'[Score] = 2 ),
4,
IF ( AND ( 'Raw Data'[Metric] = "MCARs", 'Raw Data'[Score] <= 1 ), 5, 0 )
) )))))

 

Davehus,

 

Thank you for your quick response, it works seemesly.  Have a great week. 

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.