Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Sign up nowGet Fabric certified for FREE! Don't miss your chance! Learn more
Hi,
in VBA i would have :
if 1=1 then
'step 1
'step 2
If is there any equivalent in power query?
Best,
Jacek
Solved! Go to 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.
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Yes, there is.
How to structure the statement depends on what you want to do.
And there also needs to be an else clause.
@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
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.
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
thank you
@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
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 4 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 13 | |
| 11 | |
| 9 | |
| 8 | |
| 6 |