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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
MagdoulinShams1
New Member

Power Query, Split Columns into Columns Conditinally

I have the below step code:

 

= if List.AnyTrue(List.Transform(#"Capitalized Each Word"[Delivery status], each Text.Contains(_, "/"))) then Table.SplitColumn(#"Capitalized Each Word", "Delivery status", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), {"Status", "Count"}) else #"Capitalized Each Word"

 

What I am trying to do is to split column: Delivery status into columns: Status and Count, by delimeter " ", only if column: Delivery status contains "/", otherwise, do not proceed with the split.

 

It executes perfectly when if is TRUE, but it does not execute correctly when if is FALSE, it should not split, but it splits anyways.

 

What do I need to modify here?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @MagdoulinShams1 

Thanks for the reply form Ashish_Mathur and audreygerred. You can try to use the Split Column function directly.

 

 

vyaningymsft_0-1735787356695.png

vyaningymsft_0-1735787496326.png

= Table.SplitColumn(#"Changed Type", "Delivery status", Splitter.SplitTextByDelimiter("/", QuoteStyle.Csv), {"Status", "Count"})

 

Best Regards,
Yang

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, @MagdoulinShams1 

Thanks for the reply form Ashish_Mathur and audreygerred. You can try to use the Split Column function directly.

 

 

vyaningymsft_0-1735787356695.png

vyaningymsft_0-1735787496326.png

= Table.SplitColumn(#"Changed Type", "Delivery status", Splitter.SplitTextByDelimiter("/", QuoteStyle.Csv), {"Status", "Count"})

 

Best Regards,
Yang

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

Ashish_Mathur
Super User
Super User

Hi,

Could you share some data to work with and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
audreygerred
Super User
Super User

Hi! It's ok - let the split happen on everything. Then, add a conditional column and do something similar to the below. You would say that if one column contains a /, return the value in column A, if it does not, return column B. 

audreygerred_0-1735657665193.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





I hoped to reach the desired outcome in one step, but this is a good suggestion too.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors