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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
jaryszek
Resident Rockstar
Resident Rockstar

Two steps in if statement

Hi,

 

in VBA i would have :

 

if 1=1 then

'step 1

'step 2

 

If is there any equivalent in power query?

 

Best,
Jacek

1 ACCEPTED SOLUTION

@jaryszek 

It executes only one step. 
If you need to execute two steps either under the true or false part, then it depends on what you exactly are trying to acheve here. You can create a custom function and include all the actions there for this purpose.

Hope this is helpful, if you need to share a scenario with sample data and the expected output, please do so.

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

6 REPLIES 6
ronrsnfld
Super User
Super User

Yes, there is.

How to structure the statement depends on what you want to do.

And there also needs to be an else clause.

smpa01
Community Champion
Community Champion

@jaryszek  I have taken a guess here as I am not fully sure what you meant. But can you please give the following a try and see if you meant that by changing the Toggle value

 

 

let
    Toggle =0,
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WykvMTTVU0lFKSS0AUZkpINLQwEApVgciaQSRNAJLgkgjkGQsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [name = _t, department = _t, id = _t, salary = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"name", type text}, {"department", type text}, {"id", type text}, {"salary", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Commission", each [salary]*0.2),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([name] = "name1")),
    Filter = if Toggle=1 then #"Added Custom" else #"Filtered Rows"
in
    Filter

 


========================
Did I answer your question? Mark my post as a solution!
Proud to be a Super User
My Custom Visualization Projects
• Plotting Live Sound: Live Sound
• Beautiful News: Women in Parliament, Energy Mix, Shrinking Armies
• Visual Capitalist: Working Hrs
• Others: Easing Graph, Animated Calendar
MayViz Submissions
• Week 1: View
• Week 2: View
• Week 3: View
========================
jaryszek
Resident Rockstar
Resident Rockstar

Hi,

 

ok but this is not allowing to run 2 steps? Only either step 1 or step 2? 

@jaryszek 

It executes only one step. 
If you need to execute two steps either under the true or false part, then it depends on what you exactly are trying to acheve here. You can create a custom function and include all the actions there for this purpose.

Hope this is helpful, if you need to share a scenario with sample data and the expected output, please do so.

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

jaryszek
Resident Rockstar
Resident Rockstar

thank you

Fowmy
Super User
Super User

@jaryszek 

You can use it this way. PQ is case-sensitive. Please refer to this documentation as well: 
https://docs.microsoft.com/en-us/powerquery-m/m-spec-conditionals

if 1 = 1 then step1 else  step1





Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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