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
Papillon
Frequent Visitor

If statement without else

Hello everyone,

I crosschecked the forums but couldn't find what is needed.

Actually I need a If-statement without the "else"-part:

My variable "Replacing_text" has to change its content depending on the conditions of [Obcod1]. If the conditions are not given, then the variable should keep its content as it is.

Replacing_Text = if Text.Length([Objcod1])=1 then [Langtext] else "keep the content of Replacing_text as is"

 

Anybody has a idea?

Thx in advance.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Papillon ,

Is this your expected output?

vcgaomsft_0-1700206340862.png

If so, try add a conditional column and then use fill down.

Advanced editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUSpKLchJTM7MS48vSa0oMVSK1QGKY0oYQSUwZYxhMphSJhApDHFTXLaY4dBgrhQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Objcod1 = _t, Langtext = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Objcod1", type text}, {"Langtext", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Text.Length([Objcod1])=1 then [Langtext] else null),
    #"Filled Down" = Table.FillDown(#"Added Custom",{"Custom"})
in
    #"Filled Down"

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Papillon ,

Is this your expected output?

vcgaomsft_0-1700206340862.png

If so, try add a conditional column and then use fill down.

Advanced editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUSpKLchJTM7MS48vSa0oMVSK1QGKY0oYQSUwZYxhMphSJhApDHFTXLaY4dBgrhQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Objcod1 = _t, Langtext = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Objcod1", type text}, {"Langtext", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Text.Length([Objcod1])=1 then [Langtext] else null),
    #"Filled Down" = Table.FillDown(#"Added Custom",{"Custom"})
in
    #"Filled Down"

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Hey!! Great! THX! This is exactly what I need. I will check that out... Coming back!!!

Anonymous
Not applicable

Replacing_Text = if Text.Length([Objcod1])=1 then [Langtext] else [Objcod1]

--Nate

Thank you for replying that quick. Unfortunately it doesn't work for my case. 😉 It gives me the content of [Objcod1]. What I need is to give back the content of "replacing_text" as it was valid so far.

Example:

 Row 1: Text.Length([Objcod1]) = 1 >> "replacing_text" is [Langtext]

 Row2:  Text.Length([Objcod1]) = 3 >> ""replacing_text" is ([Langtext] from Row 1) 
 Row3:  Text.Length([Objcod1]) = 4 >> ""replacing_text" is ([Langtext] from Row 1) 
 Row4:  Text.Length([Objcod1]) = 3 >> ""replacing_text" is ([Langtext] from Row 1) 
 Row5:  Text.Length([Objcod1]) = 1 >> ""replacing_text" is ([Langtext] from Row 5

Maybe this makes more clear what is needed. 😉

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 Fabric 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.