none
getting Token Eof expected in my power query please help RRS feed

  • Question

  • Domain = Text.Replace(Text.Replace((Text.Replace(Text.Lower([Website]),"https://","")),"http://","")),"www.","")

    Hi I'm trying to extract the domain of a URL in my query and i am getting a "Token Eof expected" on the . in "www." at first I thought it was the period and I needed to escape it using the char unicode but if I add any characters in there say just "www" it still complains. If there something obvious i'm missing here? This is probably my first time using powerquery but I have tried to find a solution else where including Microsoft Power Query M Formula Language Specification. Would appreciate it if someone could nudge me in the right direction. 


    • Edited by Tokyodenizen Friday, November 1, 2019 6:52 AM correction
    Friday, November 1, 2019 6:51 AM

Answers

  • Domain = Text.Replace(Text.Replace((Text.Replace(Text.Lower([Website]),"https://","")),"http://","")),"www.","")



    Hi

    Too many ( ) - bolded above. Try:

    Domain = Text.Replace(Text.Replace(Text.Replace(Text.Lower([Website]),"https://",""),"http://",""),"www.","")

    • Marked as answer by Tokyodenizen Friday, November 1, 2019 11:10 AM
    Friday, November 1, 2019 8:27 AM

All replies

  • Domain = Text.Replace(Text.Replace((Text.Replace(Text.Lower([Website]),"https://","")),"http://","")),"www.","")



    Hi

    Too many ( ) - bolded above. Try:

    Domain = Text.Replace(Text.Replace(Text.Replace(Text.Lower([Website]),"https://",""),"http://",""),"www.","")

    • Marked as answer by Tokyodenizen Friday, November 1, 2019 11:10 AM
    Friday, November 1, 2019 8:27 AM
  • Hi Lz._,

    Thank you that worked!


    Friday, November 1, 2019 11:10 AM
  • Welcome Tokyo. Alternative:

    = List.Accumulate({"https://","http://","www."}, Text.Lower([Website]),
    	(state, current) => Text.Replace(state, current, "")
    )

    Friday, November 1, 2019 11:52 AM