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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
vsatamraju
Employee
Employee

splitting the url based on condition


Hi Team,

 

I need to show the data from different tables and among them url is one fof the column. Actually i am splitting the column (that is url column) by "/" .but some times if "/" is not present in the url ,it is showing the column as blank.

 

My issue is splitting the url based on some condition .

I need to split the url based on the top most right one.if that is not present it should not split.

 

example 1: http://microsoft.com/en-us
in this case result should show the en-us

 

example 2: http://microsoft.com
in thi case result should show complete url like http://microsoft.com

 

Thanks in advance.

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @vsatamraju,

 

You can also use dax query to achieve your requirement:

 

Table:

Capture.PNG

 

Calculate column:

RightPart = if(LEN([Url])<=LEN("http://microsoft.com"),[Url],RIGHT([Url],LEN([Url])-LEN("http://microsoft.com/")))

 

Result:

Capture2.PNG

 

Regards,

Xiaoxin Sheng

 

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
jbocachica
Resolver II
Resolver II

Hi, this "M" code could help you to achieve.

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WyigpKbDS188sT87XS87XT0xKVorVQRdWio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","//","||",Replacer.ReplaceText,{"Column1"}),
#"Split Column by Delimiter" = Table.SplitColumn(#"Replaced Value","Column1",Splitter.SplitTextByDelimiter("/", QuoteStyle.Csv),{"Column1.1"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", type text}}),
#"Replaced Value2" = Table.ReplaceValue(#"Changed Type1","||","//",Replacer.ReplaceText,{"Column1.1"})
in
#"Replaced Value2"

 

Regards

John Bocachica
Senior BI Consultant
Information Workers
http://www.iwco.co
KHorseman
Community Champion
Community Champion

Rather than using the split columns method, I'd recommend writing a custom column to check conditions and copy the appropriate string.





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

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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