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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Sime
Helper I
Helper I

Case or IF Statement in Power Query

Hi All,

 

Is it possible to use a CASE or IF statement in Power Query to query mulitple conditions?

 

I'm using the following IF Statement but it is not capturing the "Encrouching Budget" line.

Is therea better way to achieve the desired result?

 

if [budget_amountcost] = 0 then "No Budget" else if[jtd_LaborAmountCost_inclUnposted] + [jtd_GL610205AmountCost] / [budget_amountcost] < .85 then "Ontrack" else if [jtd_LaborAmountCost_inclUnposted] + [jtd_GL610205AmountCost] / [budget_amountcost] < 1.01 then "Encroaching Budget" else if [jtd_LaborAmountCost_inclUnposted] + [jtd_GL610205AmountCost] / [budget_amountcost] > 1.01 then "Over Budget" else null

 

Thank you.

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @Sime 

 

There's nothing wrong with the syntax of that code so without some sample data it's hard to say why it's not working as you expect.  You need to explain what result you are expecting.

 

Can you please provide sample data or your file?

 

The only thing I'd ask you to check at this stage is whether the calculations are being carried out as you expect. 

 

For example, is it

[jtd_LaborAmountCost_inclUnposted] + [jtd_GL610205AmountCost] / [budget_amountcost] 

 

or is it

( [jtd_LaborAmountCost_inclUnposted] + [jtd_GL610205AmountCost] ) / [budget_amountcost]

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

2 REPLIES 2
PhilipTreacy
Super User
Super User

Hi @Sime 

 

There's nothing wrong with the syntax of that code so without some sample data it's hard to say why it's not working as you expect.  You need to explain what result you are expecting.

 

Can you please provide sample data or your file?

 

The only thing I'd ask you to check at this stage is whether the calculations are being carried out as you expect. 

 

For example, is it

[jtd_LaborAmountCost_inclUnposted] + [jtd_GL610205AmountCost] / [budget_amountcost] 

 

or is it

( [jtd_LaborAmountCost_inclUnposted] + [jtd_GL610205AmountCost] ) / [budget_amountcost]

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Thank you Philip.  The lack of parentheses was the cause of the issue.

Greatly appreciate your assistance.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors