cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
fsy
Regular Visitor

IF Statement error

Hi,

 

I’m trying to create a chart that compares Actual Revenues and Expenses to Budgeted Revenues and Expenses. I’m using Variance to Budget % = [Actual]-[Budget)/abs[Actual].

 

Screen Shot.PNG

 

If Actual Revenue is greater than Budgeted Revenue, I want to show a positive variance. However, if Actual Expenses is greater than Budgeted Expenses I need to show a negative variance, so I need to reverse the signs of my formula depending on whether or not I’m calculating a Revenue or Expense variance %.

 

I have a column [Category] that classifies whether or not the amount is a Revenue or Expense. I’m trying to solve for this by using the following IF statement:

 

Variance to Budget % = IF(or([Actual]=0,[Budget]=0),

                                       BLANK(),

                                              If ([Category] = “Total Revenue”, ([Actual]-[Budget])/abs([Actual])),

                                             , ([Actual]-[Budget])/abs([Actual])),*-1)

 

I get the following error:

 

Error.PNG

 

Any suggests as to what I am doing wrong? Thank you for your help!

1 ACCEPTED SOLUTION

Replace [category] with selectedvalue(tablename[category]).  but the total won't work here. I am not sure how you are going about this, but you may benefit from this video https://www.youtube.com/watch?v=ojHZkWkEY7Q/

 

 

As an aside, you should always add the table name before the column name (although this is not the issue causing the problem). https://exceleratorbi.com.au/best-practices-power-pivot-power-query-power-bi/



* Matt is a Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

View solution in original post

2 REPLIES 2

Replace [category] with selectedvalue(tablename[category]).  but the total won't work here. I am not sure how you are going about this, but you may benefit from this video https://www.youtube.com/watch?v=ojHZkWkEY7Q/

 

 

As an aside, you should always add the table name before the column name (although this is not the issue causing the problem). https://exceleratorbi.com.au/best-practices-power-pivot-power-query-power-bi/



* Matt is a Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

 Thank you very much, Matt!

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors