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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Dave-ExpSC
Helper II
Helper II

Nested IF Statement too many arguments

Can someone help me with this formula.

 

In my DATA table I can make this IF statement work:

=IF(OR([eSource]="Electricity",[eSource]="Natural Gas"),[Quantity]*0.0036,IF([eSource]="Diesel",[Quantity]*0.0364,""))

 

However if I take it one step further it fails:

=IF(OR([eSource]="Electricity",[eSource]="Natural Gas"),[Quantity]*0.0036,IF([eSource]="Diesel",[Quantity]*0.0364,IF([eSource]="LPG"),[Quantity]*.0000049,""))

Formula check highlights "LPG"

 

How can I use the IF statement to allow more than 3 criteria

 

Alternatively I tried this formula within Powerpivot that only produces and Error result

=SUMX(ENERGYtbl,IF(ENERGYtbl[eSource]="Natural Gas",ENERGYtbl[Quantity]*.0036,IF(ENERGYtbl[eSource]="Electricity",ENERGYtbl[Quantity]*.0036,IF(ENERGYtbl[eSource]="LPG",ENERGYtbl[Quantity]*.0000049,IF(ENERGYtbl[eSource]="Diesel",ENERGYtbl[Quantity]*.0364,"")))))

 

I need to have a formula that allows me to keep adding to the formula as new energy sources get added to the project.

Help is much appreciated!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

To answer your second question:

 

Alternatively I tried this formula within Powerpivot that only produces and Error result

=SUMX(ENERGYtbl,IF(ENERGYtbl[eSource]="Natural Gas",ENERGYtbl[Quantity]*.0036,IF(ENERGYtbl[eSource]="Electricity",ENERGYtbl[Quantity]*.0036,IF(ENERGYtbl[eSource]="LPG",ENERGYtbl[Quantity]*.0000049,IF(ENERGYtbl[eSource]="Diesel",ENERGYtbl[Quantity]*.0364,"")))))

 

You'd be better off storing the multipliers (0.0036, 0.0036, 0.0000049, ...) in your model as an additional column: ENERGYtbl[multiplier].

 

You then be able to create a calcaulted column 

[Something] = ENERGYtbl[Quantity] * ENERGYtbl[multiplier]

which can easily be summed

 

[Total] = SUM(ENERGYtbl[Something])

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

To answer your second question:

 

Alternatively I tried this formula within Powerpivot that only produces and Error result

=SUMX(ENERGYtbl,IF(ENERGYtbl[eSource]="Natural Gas",ENERGYtbl[Quantity]*.0036,IF(ENERGYtbl[eSource]="Electricity",ENERGYtbl[Quantity]*.0036,IF(ENERGYtbl[eSource]="LPG",ENERGYtbl[Quantity]*.0000049,IF(ENERGYtbl[eSource]="Diesel",ENERGYtbl[Quantity]*.0364,"")))))

 

You'd be better off storing the multipliers (0.0036, 0.0036, 0.0000049, ...) in your model as an additional column: ENERGYtbl[multiplier].

 

You then be able to create a calcaulted column 

[Something] = ENERGYtbl[Quantity] * ENERGYtbl[multiplier]

which can easily be summed

 

[Total] = SUM(ENERGYtbl[Something])

Thank you very much that's a good idea.

Anonymous
Not applicable

Looks like you have an extra closing brace

 

=IF(OR([eSource]="Electricity",[eSource]="Natural Gas"),[Quantity]*0.0036,IF([eSource]="Diesel",[Quantity]*0.0364,IF([eSource]="LPG"),[Quantity]*.0000049,""))

 

 

Edit: and possibly missing a closing one at the end.

Helpful resources

Announcements
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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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