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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
lousmith22
Frequent Visitor

Multiple IF Conditions in Custom Column

Hi, I'm trying to work out the YTD variance but for revenue and expense account where the formula is different for both types, but need it in the one column, any help appreciated.
if ([Account Type Number]=6 and [Budget]=0)
then 0 else [#"YTD Variance $"]/[Budget]
else if
([Account Type Number]=4 and [Budget]=0) then 0 else [Budget]/[#"YTD Variance $"]

1 REPLY 1
jennratten
Super User
Super User

Hello - I think you are missing a piece of logic.  As your description is currently written, after the first else statement the evaluation would end because there is an if and an else with no other if in between.  What you have described says that the result should be 0 when the budget equals 0 and the Account Type Number equals either 4 or 6.  But it does not when the variance over budget should be returned vs. budget over variance or what the outcome should be if none of the scenarios resolve to true.  Below should get you started.  You will need to fill in the blanks with the correct logic.  I'll be glad to help if you will provide more info.

 

let 
varVarianceOverBudget = [#"YTD Variance $"]/[Budget],
varBudgetOverVariance = [Budget]/[#"YTD Variance $"]
in 
if [Budget] = 0 and ( [Account Type Number] = 6 or [Account Type Number] = 4) then 0
else if _____ then varVarianceOverBudget 
else if _____ then varBudgetOverVariance 
else _____

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors